Skip to content

Commit

Permalink
disable context deadline check for unary RPC calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Sch committed Mar 15, 2021
1 parent 94bd102 commit 03bf773
Showing 1 changed file with 14 additions and 36 deletions.
50 changes: 14 additions & 36 deletions client/rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,7 @@ func (r *rpcClient) call(ctx context.Context, node *registry.Node, req Request,
ch <- nil
}()

var grr error

select {
case err := <-ch:
return err
case <-ctx.Done():
grr = errors.Timeout("go.micro.client", fmt.Sprintf("%v", ctx.Err()))
}

// set the stream error
if grr != nil {
stream.Lock()
stream.err = grr
stream.Unlock()

return grr
}

return nil
return <-ch
}

func (r *rpcClient) stream(ctx context.Context, node *registry.Node, req Request, opts CallOptions) (Stream, error) {
Expand Down Expand Up @@ -443,26 +425,22 @@ func (r *rpcClient) Call(ctx context.Context, request Request, response interfac
ch <- call(i)
}(i)

select {
case <-ctx.Done():
return errors.Timeout("go.micro.client", fmt.Sprintf("call timeout: %v", ctx.Err()))
case err := <-ch:
// if the call succeeded lets bail early
if err == nil {
return nil
}

retry, rerr := callOpts.Retry(ctx, request, i, err)
if rerr != nil {
return rerr
}
err := <-ch
// if the call succeeded lets bail early
if err == nil {
return nil
}

if !retry {
return err
}
retry, rerr := callOpts.Retry(ctx, request, i, err)
if rerr != nil {
return rerr
}

gerr = err
if !retry {
return err
}

gerr = err
}

return gerr
Expand Down

0 comments on commit 03bf773

Please sign in to comment.