Skip to content

Commit

Permalink
Set grpc timeout on all requests, not just the first one. (#355)
Browse files Browse the repository at this point in the history
Co-authored-by: Bjorn Melinder <[email protected]>
  • Loading branch information
bjornm and Bjorn Melinder authored Mar 8, 2024
1 parent 722aff9 commit 6eba3d6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/pkg/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ func (c *Client) SendRequest(serviceMethod string, message string, headers []str
return response.Response{Duration: time.Duration(0), Err: errors.New("no connection available"), Type: respType}
}

err = grpcurl.InvokeRPC(context.Background(), c.descriptorSource, c.conn, serviceMethod, interpolatedHeaders, loggingEventHandler, requestParser.Next)
ctx, _ := context.WithTimeout(context.Background(), time.Duration(c.timeoutMilliseconds)*time.Millisecond)
err = grpcurl.InvokeRPC(ctx, c.descriptorSource, c.conn, serviceMethod, interpolatedHeaders, loggingEventHandler, requestParser.Next)
endTime := time.Now()
if err != nil {
log.Printf("grpc response error: %s", err)
Expand Down

0 comments on commit 6eba3d6

Please sign in to comment.