|
|
|
@ -147,7 +147,7 @@ func NewClient(ctx context.Context, opts ...ClientOption) (*Client, error) { |
|
|
|
|
var r *resolver |
|
|
|
|
if options.discovery != nil { |
|
|
|
|
if target.Scheme == "discovery" { |
|
|
|
|
if r, err = newResolver(ctx, options.discovery, target); err != nil { |
|
|
|
|
if r, err = newResolver(ctx, options.discovery, target, options.balancer); err != nil { |
|
|
|
|
return nil, fmt.Errorf("[http client] new resolver failed!err: %v", options.endpoint) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
@ -211,11 +211,10 @@ func (client *Client) invoke(ctx context.Context, req *http.Request, args interf |
|
|
|
|
var done func(context.Context, balancer.DoneInfo) |
|
|
|
|
if client.r != nil { |
|
|
|
|
var ( |
|
|
|
|
err error |
|
|
|
|
node *registry.ServiceInstance |
|
|
|
|
nodes = client.r.fetch(ctx) |
|
|
|
|
err error |
|
|
|
|
node *registry.ServiceInstance |
|
|
|
|
) |
|
|
|
|
if node, done, err = client.opts.balancer.Pick(ctx, nodes); err != nil { |
|
|
|
|
if node, done, err = client.opts.balancer.Pick(ctx); err != nil { |
|
|
|
|
return nil, errors.ServiceUnavailable("NODE_NOT_FOUND", err.Error()) |
|
|
|
|
} |
|
|
|
|
scheme, addr, err := parseEndpoint(node.Endpoints) |
|
|
|
|