-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathkeepalive.py
More file actions
34 lines (25 loc) · 1.01 KB
/
Copy pathkeepalive.py
File metadata and controls
34 lines (25 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from typing import TypedDict
DEFAULT_KEEPALIVE_TIME_MS = 20_000
"""Interval with which to send keepalive pings"""
DEFAULT_KEEPALIVE_TIMEOUT_MS = 20_000
"""Timeout while waiting for server to acknowledge keepalive ping"""
DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS = 1
"""Allows connection without any active RPCs"""
DEFAULT_MAX_PINGS_WITHOUT_DATA = 0
"""Disabled"""
# https://github.com/grpc/grpc/blob/master/doc/keepalive.md
class KeepaliveConfig(TypedDict):
"""
Make make this public in the future to allow folks to configure their own keepalive settings
if there is demand for it.
"""
keepalive_time_ms: int
keepalive_timeout_ms: int
keepalive_permit_without_calls: int
max_pings_without_data: int
DEFAULT_KEEPALIVE_CONFIG: KeepaliveConfig = {
"keepalive_time_ms": DEFAULT_KEEPALIVE_TIME_MS,
"keepalive_timeout_ms": DEFAULT_KEEPALIVE_TIMEOUT_MS,
"keepalive_permit_without_calls": DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS,
"max_pings_without_data": DEFAULT_MAX_PINGS_WITHOUT_DATA,
}