From 6eba3d64bf155abec472f989273b56d4632cce92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Melinder?= Date: Fri, 8 Mar 2024 21:22:51 +0100 Subject: [PATCH] Set grpc timeout on all requests, not just the first one. (#355) Co-authored-by: Bjorn Melinder --- internal/pkg/grpc/client.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/pkg/grpc/client.go b/internal/pkg/grpc/client.go index db4f37f..333e1da 100644 --- a/internal/pkg/grpc/client.go +++ b/internal/pkg/grpc/client.go @@ -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)