mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-07 23:02:12 +02:00
add init direct
This commit is contained in:
parent
40f5515e85
commit
3c919192d7
@ -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)
|
||||
})
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user