Skip to content

Commit 1e2bb71

Browse files
authored
doc: update keepalive ClientParameters doc about doubling the interval upon GOAWAY (#7469)
1 parent 6a5a283 commit 1e2bb71

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

dialoptions.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,8 @@ func WithUserAgent(s string) DialOption {
518518

519519
// WithKeepaliveParams returns a DialOption that specifies keepalive parameters
520520
// for the client transport.
521+
//
522+
// Keepalive is disabled by default.
521523
func WithKeepaliveParams(kp keepalive.ClientParameters) DialOption {
522524
if kp.Time < internal.KeepaliveMinPingTime {
523525
logger.Warningf("Adjusting keepalive ping interval to minimum period of %v", internal.KeepaliveMinPingTime)

keepalive/keepalive.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,29 @@ type ClientParameters struct {
3434
// After a duration of this time if the client doesn't see any activity it
3535
// pings the server to see if the transport is still alive.
3636
// If set below 10s, a minimum value of 10s will be used instead.
37-
Time time.Duration // The current default value is infinity.
37+
//
38+
// Note that gRPC servers have a default EnforcementPolicy.MinTime of 5
39+
// minutes (which means the client shouldn't ping more frequently than every
40+
// 5 minutes).
41+
//
42+
// Though not ideal, it's not a strong requirement for Time to be less than
43+
// EnforcementPolicy.MinTime. Time will automatically double if the server
44+
// disconnects due to its enforcement policy.
45+
//
46+
// For more details, see
47+
// https://github.com/grpc/proposal/blob/master/A8-client-side-keepalive.md
48+
Time time.Duration
3849
// After having pinged for keepalive check, the client waits for a duration
3950
// of Timeout and if no activity is seen even after that the connection is
4051
// closed.
41-
Timeout time.Duration // The current default value is 20 seconds.
52+
//
53+
// If keepalive is enabled, and this value is not explicitly set, the default
54+
// is 20 seconds.
55+
Timeout time.Duration
4256
// If true, client sends keepalive pings even with no active RPCs. If false,
4357
// when there are no active RPCs, Time and Timeout will be ignored and no
4458
// keepalive pings will be sent.
45-
PermitWithoutStream bool // false by default.
59+
PermitWithoutStream bool
4660
}
4761

4862
// ServerParameters is used to set keepalive and max-age parameters on the

0 commit comments

Comments
 (0)