fix(client-python): keepalive options, typed error mapping with status code, open-enum names, malformed-reply checks (CPY-001..004, #257)
This commit is contained in:
@@ -455,6 +455,32 @@ building it inside `asyncio.to_thread` raises
|
||||
`RuntimeError: There is no current event loop in thread 'asyncio_N'`. Callers that
|
||||
build their own channel should keep `create_channel` on the loop thread.
|
||||
|
||||
## Keepalive And Error Mapping
|
||||
|
||||
The channel sends an HTTP/2 PING every 30 s, waits 10 s for the acknowledgement,
|
||||
and pings even while no call is active (`grpc.keepalive_time_ms`,
|
||||
`grpc.keepalive_timeout_ms`, `grpc.keepalive_permit_without_calls`, and
|
||||
`grpc.http2.max_pings_without_data=0` so pings continue with no data in flight).
|
||||
A half-open connection (firewall idle-out, host power loss) therefore makes a
|
||||
deadline-less `stream_events()` iterator raise `MxGatewayTransportError` within
|
||||
about 40 s instead of hanging forever. Tune with `ClientOptions(keepalive_time=...,
|
||||
keepalive_timeout=..., keepalive_permit_without_calls=...)`; `keepalive_time=None`
|
||||
disables it. Keep `keepalive_time` at or above the gateway's permitted client ping
|
||||
interval (`MxGateway:*` keepalive policy, 30 s by default); pinging faster makes
|
||||
the gateway send GOAWAY (`too_many_pings`).
|
||||
|
||||
gRPC failures map to `MxGatewayAuthenticationError`, `MxGatewayAuthorizationError`,
|
||||
`MxGatewayTimeoutError` (`DEADLINE_EXCEEDED`), `MxGatewayUnavailableError`
|
||||
(`UNAVAILABLE` / `RESOURCE_EXHAUSTED`) or the base `MxGatewayTransportError`. Every
|
||||
transport error carries the gRPC status in `.code`, and credential-shaped text
|
||||
(`mxgw_...` keys, `Bearer`) is scrubbed from the server-supplied details. Enum
|
||||
values newer than the generated code (a new status category or protocol status
|
||||
code) are reported by number instead of raising `ValueError`.
|
||||
|
||||
`register`, `add_item`, `add_item2`, the bulk helpers, `read_bulk` and
|
||||
`drain_events` raise `MalformedReplyError` when an `OK` reply lacks the expected
|
||||
payload, instead of returning handle `0` or an empty list.
|
||||
|
||||
## CLI
|
||||
|
||||
The CLI emits deterministic JSON for automation:
|
||||
|
||||
Reference in New Issue
Block a user