Skip to content

Commit 84dcccd

Browse files
Merge pull request #20 from speakeasy-api/feature/spe-483
fix: add a timeout to ingest request
2 parents 3132e5b + 5edcb31 commit 84dcccd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

transport.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"crypto/tls"
66
"net"
7+
"time"
78

89
"github.com/speakeasy-api/speakeasy-go-sdk/internal/log"
910
"github.com/speakeasy-api/speakeasy-schemas/grpc/go/registry/embedaccesstoken"
@@ -15,6 +16,8 @@ import (
1516
"google.golang.org/grpc/metadata"
1617
)
1718

19+
var GRPCIngestTimeout = 1 * time.Second
20+
1821
type DialerFunc func() func(context.Context, string) (net.Conn, error)
1922

2023
type GRPCClient struct {
@@ -34,6 +37,9 @@ func newGRPCClient(apiKey, serverURL string, secure bool, grpcDialer DialerFunc)
3437
}
3538

3639
func (c *GRPCClient) SendToIngest(ctx context.Context, req *ingest.IngestRequest) {
40+
ctx, cancel := context.WithTimeout(ctx, GRPCIngestTimeout)
41+
defer cancel()
42+
3743
conn, err := c.getConn(ctx)
3844
if err != nil {
3945
log.From(ctx).Error("speakeasy-sdk: failed to create grpc connection", zap.Error(err))

0 commit comments

Comments
 (0)