Skip to content

Commit

Permalink
feat & refactor: use consul as register and refactor rpc client imple…
Browse files Browse the repository at this point in the history
…ment (#133)

Co-authored-by: intyou <[email protected]>
  • Loading branch information
mo3et and intyouss authored Sep 20, 2023
1 parent 72c28e3 commit 6c39e4f
Show file tree
Hide file tree
Showing 60 changed files with 2,179 additions and 1,650 deletions.
10 changes: 8 additions & 2 deletions app/comment/service/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/go-kratos/kratos/v2/config"
"github.com/go-kratos/kratos/v2/config/file"
"github.com/go-kratos/kratos/v2/log"
"github.com/go-kratos/kratos/v2/registry"
"github.com/go-kratos/kratos/v2/transport/grpc"
"github.com/go-kratos/kratos/v2/transport/http"

Expand All @@ -26,14 +27,15 @@ func init() {
flag.StringVar(&flagConf, "conf", "../configs", "config path, eg: -conf config.yaml")
}

func newApp(logger log.Logger, gs *grpc.Server, hs *http.Server) *kratos.App {
func newApp(logger log.Logger, gs *grpc.Server, hs *http.Server, rr registry.Registrar) *kratos.App {
return kratos.New(
kratos.Name(Name),
kratos.Logger(logger),
kratos.Server(
gs,
hs,
),
kratos.Registrar(rr),
)
}

Expand All @@ -60,7 +62,11 @@ func main() {
if err := c.Scan(&bc); err != nil {
panic(err)
}
app, cleanup, err := wireApp(bc.Server, bc.Client, bc.Data, bc.Jwt, logger)
var rc conf.Registry
if err := c.Scan(&rc); err != nil {
panic(err)
}
app, cleanup, err := wireApp(bc.Server, &rc, bc.Data, bc.Jwt, logger)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion app/comment/service/cmd/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ import (
)

// wireApp init kratos application.
func wireApp(*conf.Server, *conf.Client, *conf.Data, *conf.JWT, log.Logger) (*kratos.App, func(), error) {
func wireApp(*conf.Server, *conf.Registry, *conf.Data, *conf.JWT, log.Logger) (*kratos.App, func(), error) {
panic(wire.Build(server.ProviderSet, data.ProviderSet, biz.ProviderSet, service.ProviderSet, newApp))
}
14 changes: 8 additions & 6 deletions app/comment/service/cmd/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6c39e4f

Please sign in to comment.