-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python(feature): support keepalive (#86)
- Loading branch information
1 parent
0ea61e8
commit 43d1ec9
Showing
2 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from typing import TypedDict | ||
|
||
DEFAULT_KEEPALIVE_TIME_MS = 20_000 | ||
"""Interval with which to send keepalive pings""" | ||
|
||
DEFAULT_KEEPALIVE_TIMEOUT_MS = 60_000 | ||
"""Timeout while waiting for server to acknowledge keepalive ping""" | ||
|
||
DEFAULT_KEEPALIVE_PERMIT_WITHOUT_CALLS = 0 | ||
"""Disabled""" | ||
|
||
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters