Skip to content

Commit

Permalink
Add keepalive timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
klapkov authored and geofffranks committed Apr 19, 2023
1 parent 5e8522d commit 1f63346
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions locket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import (
)

type ClientLocketConfig struct {
LocketAddress string `json:"locket_address,omitempty" yaml:"locket_address,omitempty"`
LocketCACertFile string `json:"locket_ca_cert_file,omitempty" yaml:"locket_ca_cert_file,omitempty"`
LocketClientCertFile string `json:"locket_client_cert_file,omitempty" yaml:"locket_client_cert_file,omitempty"`
LocketClientKeyFile string `json:"locket_client_key_file,omitempty" yaml:"locket_client_key_file,omitempty"`
LocketAddress string `json:"locket_address,omitempty" yaml:"locket_address,omitempty"`
LocketCACertFile string `json:"locket_ca_cert_file,omitempty" yaml:"locket_ca_cert_file,omitempty"`
LocketClientCertFile string `json:"locket_client_cert_file,omitempty" yaml:"locket_client_cert_file,omitempty"`
LocketClientKeyFile string `json:"locket_client_key_file,omitempty" yaml:"locket_client_key_file,omitempty"`
LocketClientKeepAliveTime int `json:"locket_client_keepalive_time,omitempty" yaml:"locket_client_keepalive_time,omitempty"`
LocketClientKeepAliveTimeout int `json:"locket_client_keepalive_timeout,omitempty" yaml:"locket_client_keepalive_timeout,omitempty"`
}

func NewClientSkipCertVerify(logger lager.Logger, config ClientLocketConfig) (models.LocketClient, error) {
Expand Down Expand Up @@ -59,7 +61,8 @@ func newClientInternal(logger lager.Logger, config ClientLocketConfig, skipCertV
grpc.WithBlock(),
grpc.WithTimeout(10*time.Second), // ensure that grpc won't keep retrying forever
grpc.WithKeepaliveParams(keepalive.ClientParameters{
Time: 10 * time.Second,
Time: time.Duration(config.LocketClientKeepAliveTime) * time.Second,
Timeout: time.Duration(config.LocketClientKeepAliveTimeout) * time.Second,
}),
)
if err != nil {
Expand Down

0 comments on commit 1f63346

Please sign in to comment.