3 * Copyright 2017 gRPC authors.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 // Package keepalive defines configurable parameters for point-to-point healthcheck.
26 // ClientParameters is used to set keepalive parameters on the client-side.
27 // These configure how the client will actively probe to notice when a connection is broken
28 // and send pings so intermediaries will be aware of the liveness of the connection.
29 // Make sure these parameters are set in coordination with the keepalive policy on the server,
30 // as incompatible settings can result in closing of connection.
31 type ClientParameters struct {
32 // After a duration of this time if the client doesn't see any activity it pings the server to see if the transport is still alive.
33 Time time.Duration // The current default value is infinity.
34 // After having pinged for keepalive check, the client waits for a duration of Timeout and if no activity is seen even after that
35 // the connection is closed.
36 Timeout time.Duration // The current default value is 20 seconds.
37 // If true, client runs keepalive checks even with no active RPCs.
38 PermitWithoutStream bool // false by default.
41 // ServerParameters is used to set keepalive and max-age parameters on the server-side.
42 type ServerParameters struct {
43 // MaxConnectionIdle is a duration for the amount of time after which an idle connection would be closed by sending a GoAway.
44 // Idleness duration is defined since the most recent time the number of outstanding RPCs became zero or the connection establishment.
45 MaxConnectionIdle time.Duration // The current default value is infinity.
46 // MaxConnectionAge is a duration for the maximum amount of time a connection may exist before it will be closed by sending a GoAway.
47 // A random jitter of +/-10% will be added to MaxConnectionAge to spread out connection storms.
48 MaxConnectionAge time.Duration // The current default value is infinity.
49 // MaxConnectinoAgeGrace is an additive period after MaxConnectionAge after which the connection will be forcibly closed.
50 MaxConnectionAgeGrace time.Duration // The current default value is infinity.
51 // After a duration of this time if the server doesn't see any activity it pings the client to see if the transport is still alive.
52 Time time.Duration // The current default value is 2 hours.
53 // After having pinged for keepalive check, the server waits for a duration of Timeout and if no activity is seen even after that
54 // the connection is closed.
55 Timeout time.Duration // The current default value is 20 seconds.
58 // EnforcementPolicy is used to set keepalive enforcement policy on the server-side.
59 // Server will close connection with a client that violates this policy.
60 type EnforcementPolicy struct {
61 // MinTime is the minimum amount of time a client should wait before sending a keepalive ping.
62 MinTime time.Duration // The current default value is 5 minutes.
63 // If true, server expects keepalive pings even when there are no active streams(RPCs).
64 PermitWithoutStream bool // false by default.