Differentiate between request and call timeouts

This commit is contained in:
Asim 2016-11-22 10:44:32 +01:00
parent 22f212c274
commit b05b42eccd

View File

@ -124,7 +124,7 @@ func (r *rpcClient) call(ctx context.Context, address string, req Request, resp
return err return err
case <-ctx.Done(): case <-ctx.Done():
grr = ctx.Err() grr = ctx.Err()
return errors.New("go.micro.client", fmt.Sprintf("%v", ctx.Err()), 408) return errors.New("go.micro.client", fmt.Sprintf("request timeout: %v", ctx.Err()), 408)
} }
} }
@ -176,7 +176,7 @@ func (r *rpcClient) stream(ctx context.Context, address string, req Request, opt
case err := <-ch: case err := <-ch:
grr = err grr = err
case <-ctx.Done(): case <-ctx.Done():
grr = errors.New("go.micro.client", fmt.Sprintf("%v", ctx.Err()), 408) grr = errors.New("go.micro.client", fmt.Sprintf("request timeout: %v", ctx.Err()), 408)
} }
if grr != nil { if grr != nil {
@ -301,7 +301,7 @@ func (r *rpcClient) Call(ctx context.Context, request Request, response interfac
select { select {
case <-ctx.Done(): case <-ctx.Done():
return errors.New("go.micro.client", fmt.Sprintf("%v", ctx.Err()), 408) return errors.New("go.micro.client", fmt.Sprintf("call timeout: %v", ctx.Err()), 408)
case err := <-ch: case err := <-ch:
// if the call succeeded lets bail early // if the call succeeded lets bail early
if err == nil { if err == nil {
@ -412,7 +412,7 @@ func (r *rpcClient) Stream(ctx context.Context, request Request, opts ...CallOpt
select { select {
case <-ctx.Done(): case <-ctx.Done():
return nil, errors.New("go.micro.client", fmt.Sprintf("%v", ctx.Err()), 408) return nil, errors.New("go.micro.client", fmt.Sprintf("call timeout: %v", ctx.Err()), 408)
case rsp := <-ch: case rsp := <-ch:
// if the call succeeded lets bail early // if the call succeeded lets bail early
if rsp.err == nil { if rsp.err == nil {