diff --git a/pkg/net/rpc/warden/CHANGELOG.md b/pkg/net/rpc/warden/CHANGELOG.md index 142bc8905..f249e24e4 100644 --- a/pkg/net/rpc/warden/CHANGELOG.md +++ b/pkg/net/rpc/warden/CHANGELOG.md @@ -1,4 +1,5 @@ ### net/rpc/warden + ##### Version 1.1.12 1. 设置 caller 为 no_user 如果 user 不存在 diff --git a/pkg/net/rpc/warden/client.go b/pkg/net/rpc/warden/client.go index f8b2395e5..5e892b459 100644 --- a/pkg/net/rpc/warden/client.go +++ b/pkg/net/rpc/warden/client.go @@ -14,12 +14,12 @@ import ( "github.com/bilibili/kratos/pkg/conf/flagvar" "github.com/bilibili/kratos/pkg/ecode" "github.com/bilibili/kratos/pkg/naming" - "github.com/bilibili/kratos/pkg/naming/discovery" nmd "github.com/bilibili/kratos/pkg/net/metadata" "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,7 +156,7 @@ 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 { - resolver.Register(discovery.Builder()) + resolver.Register(direct.New()) c := new(Client) if err := c.SetConfig(conf); err != nil { panic(err) @@ -170,7 +170,7 @@ 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 { - resolver.Register(discovery.Builder()) + resolver.Register(direct.New()) _once.Do(func() { _defaultClient = NewClient(nil) }) @@ -226,7 +226,7 @@ func (c *Client) UseOpt(opt ...grpc.DialOption) *Client { // Dial creates a client connection to the given target. // Target format is scheme://authority/endpoint?query_arg=value -// example: discovery://default/account.account.service?cluster=shfy01&cluster=shfy02 +// example: direct://default/192.168.1.1:8080,192.168.1.2:8081 func (c *Client) Dial(ctx context.Context, target string, opt ...grpc.DialOption) (conn *grpc.ClientConn, err error) { if !c.conf.NonBlock { c.opt = append(c.opt, grpc.WithBlock()) diff --git a/pkg/net/rpc/warden/internal/examples/client/client.go b/pkg/net/rpc/warden/internal/examples/client/client.go index 85eb52c7a..0ccc08428 100644 --- a/pkg/net/rpc/warden/internal/examples/client/client.go +++ b/pkg/net/rpc/warden/internal/examples/client/client.go @@ -14,7 +14,7 @@ import ( func main() { log.Init(&log.Config{Stdout: true}) flag.Parse() - conn, err := warden.NewClient(nil).Dial(context.Background(), "127.0.0.1:8081") + conn, err := warden.NewClient(nil).Dial(context.Background(), "direct://d/127.0.0.1:8081") if err != nil { panic(err) }