Fix breaks

This commit is contained in:
Asim Aslam 2019-01-18 15:47:50 +00:00 committed by Vasiliy Tolstov
parent adcda62197
commit 04b4656653
2 changed files with 20 additions and 10 deletions

26
http.go
View File

@ -54,7 +54,13 @@ func (h *httpClient) next(request client.Request, opts client.CallOptions) (sele
return next, nil
}
func (h *httpClient) call(ctx context.Context, address string, req client.Request, rsp interface{}, opts client.CallOptions) error {
func (h *httpClient) call(ctx context.Context, node *registry.Node, req client.Request, rsp interface{}, opts client.CallOptions) error {
// set the address
address := node.Address
if node.Port > 0 {
address = fmt.Sprintf("%s:%d", address, node.Port)
}
header := make(http.Header)
if md, ok := metadata.FromContext(ctx); ok {
for k, v := range md {
@ -116,7 +122,13 @@ func (h *httpClient) call(ctx context.Context, address string, req client.Reques
return nil
}
func (h *httpClient) stream(ctx context.Context, address string, req client.Request, opts client.CallOptions) (client.Stream, error) {
func (h *httpClient) stream(ctx context.Context, node *registry.Node, req client.Request, opts client.CallOptions) (client.Stream, error) {
// set the address
address := node.Address
if node.Port > 0 {
address = fmt.Sprintf("%s:%d", address, node.Port)
}
header := make(http.Header)
if md, ok := metadata.FromContext(ctx); ok {
for k, v := range md {
@ -249,14 +261,8 @@ func (h *httpClient) Call(ctx context.Context, req client.Request, rsp interface
return errors.InternalServerError("go.micro.client", err.Error())
}
// set the address
addr := node.Address
if node.Port > 0 {
addr = fmt.Sprintf("%s:%d", addr, node.Port)
}
// make the call
err = hcall(ctx, addr, req, rsp, callOpts)
err = hcall(ctx, node, req, rsp, callOpts)
h.opts.Selector.Mark(req.Service(), node, err)
return err
}
@ -350,7 +356,7 @@ func (h *httpClient) Stream(ctx context.Context, req client.Request, opts ...cli
addr = fmt.Sprintf("%s:%d", addr, node.Port)
}
stream, err := h.stream(ctx, addr, req, callOpts)
stream, err := h.stream(ctx, node, req, callOpts)
h.opts.Selector.Mark(req.Service(), node, err)
return stream, err
}

View File

@ -40,6 +40,10 @@ func (h *httpRequest) Service() string {
return h.service
}
func (h *httpRequest) Method() string {
return h.method
}
func (h *httpRequest) Endpoint() string {
return h.method
}