Giter Site home page Giter Site logo

sniper's People

Contributors

andyjia avatar cdog34 avatar flyqie avatar fuwensun avatar giftdad avatar lancercomet avatar liloupar avatar michael2008s avatar ononee avatar savingrun avatar sp0cket avatar swiftslee avatar taoso avatar tydsc avatar verthandii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sniper's Issues

关于sniper的各层版本命名问题

默认rpc下会生成版本v1,例如 app/v1/service.proto
对应的server会生成 --> appserver1
请问是不是应当对应的创建: rpc(app/v1/service.proto) --> server(appserver1)-->service(appservice1) --> dao(appdao1)

不清楚为什么install一直EOF

安装不了

go install github.com/go-kiss/sniper/cmd/sniper@latest
go: github.com/go-kiss/sniper/cmd/sniper@latest: module github.com/go-kiss/sniper/cmd/sniper: Get "https://proxy.golang.com.cn/github.com/go-kiss/sniper/cmd/sniper/@v/list": EOF

twirp error unknown: failed to write response, 0 of 59 bytes written: http: Handler timeout

获取数据并返回Todo的对象的json的代码块

func (s *Server) Read(ctx context.Context, req *pb.ReadRequest) (*pb.ReadResponse, error) {
	var ida int64
	var title string
	var desc string
	result, err := todo.Read(1)

	defer result.Close()
	for result.Next() {
		result.Scan(&ida, &title, &desc)
		break
	}
	log.Get(ctx).Infof("%d %s %s", ida, title, desc)

	todo := &pb.ToDo{Id: ida, Title: title, Description: desc}
	resp := &pb.ReadResponse{Api: "1", ToDo: todo}
	log.Get(ctx).Infof("todo=%v", todo)
	log.Get(ctx).Infof("resp=%v", resp)
	return resp, err
}

程序执行结果的部分,todo和resp的结果都OK,write response时提示超时的错误信息。

INFO[0016] todo=id:1 title:"a" description:"b"           app_id=localapp device="<nil>" env=dev instance_id=mac.local mobi_app="<nil>" platform="<nil>" trace_id=bc7f7c4690d3ef5 uid="<nil>" version="<nil>"
INFO[0016] resp=api:"1" toDo:<id:1 title:"a" description:"b" >   app_id=localapp device="<nil>" env=dev instance_id=mac.local mobi_app="<nil>" platform="<nil>" trace_id=bc7f7c4690d3ef5 uid="<nil>" version="<nil>"
ERRO[0176] twirp error unknown: failed to write response, 0 of 59 bytes written: http: Handler timeout  app_id=localapp device="<nil>" env=dev instance_id=mac.local mobi_app="<nil>" platform="<nil>" trace_id=bc7f7c4690d3ef5 uid="<nil>" version="<nil>"

service.twirp.go的代码出现的错误
函数:serveReadForm

	if n, err := resp.Write(respBytes); err != nil {
		msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())

如何更好的区分内外部服务?

  1. 因为业务需要,想在windows起一套内部服务,但是想到编译的时候会因为一些windows的包或者linux的包无法编译。
    想请问一下如何较好的解决这个问题?

  2. 如果外部服务调用内部服务的话,是直接用tiwrp生成的client来请求还是写http请求?这个请求是否应该是在外部服务的dao层?

基础类型如何复用?

上次我提了一个dao层复用的问题,今天又遇到一个基础类型的protoc如何复用的问题:
shopAdmin protoc:
message goods{...}
shopFront protoc:
message goods{...}
这两个protoc都有goods这个基础的类型,如何做才能比较优美的实现复用?

脚手架使用单独入口之后出现问题

安装所需扩展、执行git clone https://github.com/bilibili/sniper.git .、执行go run cmd/sniper/main.go rpc --service=foo均无报错.
但执行go run main.go server --port=8080时出错
build command-line-arguments: cannot load sniper/cmd/falsework: malformed module path "sniper/cmd/falsework": missing dot in first path element
删除掉main.go的falsework内容后重新执行,出错改为

# sniper/cmd/server
cmd/server/http.go:28:33: cannot use hooks (type *"github.com/bilibili/twirp".ServerHooks) as type *"github.com/twitchtv/twirp".ServerHooks in argument to foo_v1.NewFooServer
cmd/server/main.go:137:9: too many arguments in call to initMux
	have (*http.ServeMux, bool)
	want (*http.ServeMux)

请问如何解决?望回复,谢谢

codahale/hdrhistogram repo url has been transferred under the github HdrHstogram umbrella

Problem

The codahale/hdrhistogram repo has been transferred under the github HdrHstogram umbrella with the help from the original author in Sept 2020 (new repo url https://github.com/HdrHistogram/hdrhistogram-go). The main reasons are to group all implementations under the same roof and to provide more active contribution from the community as the original repository was archived several years ago.

The dependency URL should be modified to point to the new repository URL. The tag "v0.9.0" was applied at the point of transfer and will reflect the exact code that was frozen in the original repository.

If you are using Go modules, you can update to the exact point of transfer using the @v0.9.0 tag in your go get command.

go mod edit -replace github.com/codahale/hdrhistogram=github.com/HdrHistogram/[email protected]

Performance Improvements

From the point of transfer, up until now (mon 16 aug 2021), we've released 3 versions that aim support the standard HdrHistogram serialization/exposition formats, and deeply improve READ performance.
We recommend to update to the latest version.

请教一个该项目本身的问题

据我所知,b站已有一套开源的go微服务框架kratos,里面的功能也比较完备。
请问,为何不使用kratos这套框架,而要重新造个“轮子”呢?
期待答复

service层的作用是什么,rpc参数是推荐传递到dao层吗?

GetArticleDetail这个服务做例子:
rpc GetArticleDetail(GetArticleDetailRequest) returns (GetArticleDetailResponse)

目前sniper的访问顺序依次是:
server(param GetArticleDetailRequest) --> service (param GetArticleDetailRequest)--> dao(param GetArticleDetailRequest)

那么,

  1. service主要的角色是什么?负责处理的业务逻辑是哪块?和server层的分工是什么?
  2. 还有就是GetArticleDetailRequest这个rpc的参数推荐一直传递service和dao层吗?
  3. 这个service层能复用于多个server层吗?

拜托分享sniper使用envoy的实践

请问sniper在部署的时候如何使用envoy?是不是所有的http访问都先经过envoy,由envoy中转。能否分享一下sniper使用envoy的实践经验。由于envoy的文章很少,根据thought.md中的描述

对于 redis 和 http 服务,我们用的是 envoy
拜托分享一下envoy的实践。

实践中dao层如何复用?

我们在使用sniper的过程中,dao层的复用拿捏不太准,例如:有两个服务
--shopAdmin(商城后端服务接口)
-- shopAdminDao
--shopHome(商城前端服务接口)
--shopHomeDao
在dao层有很多方法可以复用(例如:获取商品详情),这个应当通过[内部服务service的接口]去调用,还是dao层直接通过代码依赖来调用来实现代码的复用呢?那种调用方式更合理呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.