Skip to content
Snippets Groups Projects
Commit 5eaad8f8 authored by Jake Taylor's avatar Jake Taylor
Browse files

adjusted client keepalive options, allowing them to be configured

parent 191473de
No related branches found
No related tags found
1 merge request!11Release
...@@ -22,7 +22,6 @@ import ( ...@@ -22,7 +22,6 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/connectivity" "google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"
"google.golang.org/grpc/keepalive"
"math" "math"
"net" "net"
"strings" "strings"
...@@ -32,22 +31,6 @@ import ( ...@@ -32,22 +31,6 @@ import (
"time" "time"
) )
const infinityTime = time.Duration(math.MaxInt64)
//4 MB
const MaxWindowSize = math.MaxInt32
// KaClientOpts are the keepalive options for clients
// TODO: Set via configuration
var KaClientOpts = keepalive.ClientParameters{
// Never ping to keepalive
Time: infinityTime,
// 60s after ping before closing
Timeout: 60 * time.Second,
// For all connections, with and without streaming
PermitWithoutStream: true,
}
// Information used to describe a connection to a host // Information used to describe a connection to a host
type Host struct { type Host struct {
// System-wide ID of the Host // System-wide ID of the Host
...@@ -396,7 +379,7 @@ func (h *Host) connectHelper() (err error) { ...@@ -396,7 +379,7 @@ func (h *Host) connectHelper() (err error) {
dialOpts := []grpc.DialOption{ dialOpts := []grpc.DialOption{
grpc.WithBlock(), grpc.WithBlock(),
grpc.WithKeepaliveParams(KaClientOpts), grpc.WithKeepaliveParams(h.params.KaClientOpts),
securityDial, securityDial,
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
package connect package connect
import ( import (
"google.golang.org/grpc/keepalive"
"time" "time"
) )
...@@ -34,6 +35,9 @@ type HostParams struct { ...@@ -34,6 +35,9 @@ type HostParams struct {
// List of sending errors that are deemed unimportant // List of sending errors that are deemed unimportant
// Reception of these errors will not update the Metric state // Reception of these errors will not update the Metric state
ExcludeMetricErrors []string ExcludeMetricErrors []string
// KeepAlive Options for Host connections
KaClientOpts keepalive.ClientParameters
} }
// GetDefaultHostParams Get default set of host params // GetDefaultHostParams Get default set of host params
...@@ -47,5 +51,13 @@ func GetDefaultHostParams() HostParams { ...@@ -47,5 +51,13 @@ func GetDefaultHostParams() HostParams {
SendTimeout: 2 * time.Minute, SendTimeout: 2 * time.Minute,
EnableMetrics: false, EnableMetrics: false,
ExcludeMetricErrors: make([]string, 0), ExcludeMetricErrors: make([]string, 0),
KaClientOpts: keepalive.ClientParameters{
// Send keepAlive every Time interval
Time: 5 * time.Second,
// Timeout after last successful keepAlive to close connection
Timeout: 60 * time.Second,
// For all connections, with and without streaming
PermitWithoutStream: true,
},
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment