From ffbc4255d73128d32c0cb6b9c56ada63e24dc355 Mon Sep 17 00:00:00 2001 From: Peter Ebden Date: Tue, 23 Jul 2024 16:56:27 +0100 Subject: [PATCH] Add gRPC keepalive parameters --- ChangeLog | 4 ++++ VERSION | 2 +- grpcutil/BUILD | 1 + grpcutil/dial.go | 6 ++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ea0c8457..20c9486b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Version 11.11.1 +--------------- + * Add keepalive config to gRPC dial parameters + Version 11.11.0 --------------- * Add a gRPC API to Lucidity which can be used to programmatically retrieve workers diff --git a/VERSION b/VERSION index 4b8f5876..ef772f7a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -11.11.0 +11.11.1 diff --git a/grpcutil/BUILD b/grpcutil/BUILD index 29a0d8a7..bcdc4df4 100644 --- a/grpcutil/BUILD +++ b/grpcutil/BUILD @@ -13,6 +13,7 @@ go_library( "///third_party/go/google.golang.org_grpc//grpclog", "///third_party/go/google.golang.org_grpc//health", "///third_party/go/google.golang.org_grpc//health/grpc_health_v1", + "///third_party/go/google.golang.org_grpc//keepalive", "///third_party/go/google.golang.org_grpc//metadata", "///third_party/go/google.golang.org_grpc//reflection", "///third_party/go/gopkg.in_op_go-logging.v1//:go-logging.v1", diff --git a/grpcutil/dial.go b/grpcutil/dial.go index 78f11b0b..ec90a4ad 100644 --- a/grpcutil/dial.go +++ b/grpcutil/dial.go @@ -6,9 +6,11 @@ import ( "crypto/x509" "io/ioutil" "strings" + "time" "google.golang.org/grpc" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/keepalive" ) // Dial is a convenience function wrapping up some common gRPC functionality. @@ -22,6 +24,10 @@ func Dial(address string, tls bool, caFile, tokenFile string) (*grpc.ClientConn, func DialOptions(tokenFile string) []grpc.DialOption { opts := []grpc.DialOption{ grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(419430400)), + grpc.WithKeepaliveParams(keepalive.ClientParameters{ + Time: 20 * time.Second, + Timeout: 20 * time.Second, + }), } if tokenFile == "" { return opts