From 3c919192d7904dc2ee4abc62d096a55bf4fd44ab Mon Sep 17 00:00:00 2001 From: longXboy Date: Thu, 23 May 2019 14:02:27 +0800 Subject: [PATCH] add init direct --- pkg/net/rpc/warden/client.go | 6 ------ pkg/net/rpc/warden/server.go | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/net/rpc/warden/client.go b/pkg/net/rpc/warden/client.go index b3681df68..d7f308c75 100644 --- a/pkg/net/rpc/warden/client.go +++ b/pkg/net/rpc/warden/client.go @@ -18,8 +18,6 @@ import ( "github.com/bilibili/kratos/pkg/net/netutil/breaker" "github.com/bilibili/kratos/pkg/net/rpc/warden/balancer/p2c" "github.com/bilibili/kratos/pkg/net/rpc/warden/internal/status" - "github.com/bilibili/kratos/pkg/net/rpc/warden/resolver" - "github.com/bilibili/kratos/pkg/net/rpc/warden/resolver/direct" "github.com/bilibili/kratos/pkg/net/trace" xtime "github.com/bilibili/kratos/pkg/time" @@ -156,8 +154,6 @@ func NewConn(target string, opt ...grpc.DialOption) (*grpc.ClientConn, error) { // NewClient returns a new blank Client instance with a default client interceptor. // opt can be used to add grpc dial options. func NewClient(conf *ClientConfig, opt ...grpc.DialOption) *Client { - // Do not initialize in the registration, otherwise it may cause the resvoler in the business code to not register. - resolver.Register(direct.New()) c := new(Client) if err := c.SetConfig(conf); err != nil { panic(err) @@ -171,8 +167,6 @@ func NewClient(conf *ClientConfig, opt ...grpc.DialOption) *Client { // DefaultClient returns a new default Client instance with a default client interceptor and default dialoption. // opt can be used to add grpc dial options. func DefaultClient() *Client { - // Do not initialize in the registration, otherwise it may cause the resvoler in the business code to not register. - resolver.Register(direct.New()) _once.Do(func() { _defaultClient = NewClient(nil) }) diff --git a/pkg/net/rpc/warden/server.go b/pkg/net/rpc/warden/server.go index e35c291f9..0149732de 100644 --- a/pkg/net/rpc/warden/server.go +++ b/pkg/net/rpc/warden/server.go @@ -19,6 +19,8 @@ import ( //this package is for json format response _ "github.com/bilibili/kratos/pkg/net/rpc/warden/internal/encoding/json" "github.com/bilibili/kratos/pkg/net/rpc/warden/internal/status" + "github.com/bilibili/kratos/pkg/net/rpc/warden/resolver" + "github.com/bilibili/kratos/pkg/net/rpc/warden/resolver/direct" "github.com/pkg/errors" "google.golang.org/grpc" @@ -135,6 +137,7 @@ func (s *Server) handle() grpc.UnaryServerInterceptor { func init() { addFlag(flag.CommandLine) + resolver.Register(direct.New()) } func addFlag(fs *flag.FlagSet) {