connect: add gRPC keep-alive (#4961)

This commit is contained in:
Denis Mishin 2024-02-13 18:26:14 -05:00 committed by GitHub
parent c6d1f17100
commit 2db2bd09a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 4 deletions

View file

@ -25,8 +25,9 @@ func New(
ctx context.Context,
endpoint string,
tokenProvider TokenProviderFn,
dialOpts ...grpc.DialOption,
) (*grpc.ClientConn, error) {
cfg, err := getConfig(endpoint)
cfg, err := getConfig(endpoint, dialOpts...)
if err != nil {
return nil, err
}

View file

@ -25,8 +25,11 @@ type config struct {
// NewConfig returns a new Config from an endpoint string, that has to be in a URL format.
// The endpoint can be either http:// or https:// that will be used to determine whether TLS should be used.
// if port is not specified, it will be inferred from the scheme (80 for http, 443 for https).
func getConfig(endpoint string) (*config, error) {
c := new(config)
func getConfig(
endpoint string,
opts ...grpc.DialOption,
) (*config, error) {
c := &config{opts: opts}
err := c.parseEndpoint(endpoint)
if err != nil {
return nil, fmt.Errorf("invalid endpoint: %w", err)