angzarr_client.server¶
Common server utilities for angzarr Python examples.
Async (grpc.aio) gRPC server with built-in health checking and a
readiness supervisor that mirrors the Rust client’s
readiness::run_supervisor. The supervisor flips the health status to
SERVING only once every probe is passing.
Supports both TCP and Unix Domain Socket (UDS) transports.
Audit #68 design call: this module is async-native (replaces the prior
sync grpcio.server + daemon-thread supervisor). Public sync entry
points (run_*_server) preserve the blocking shape callers rely on
by running the asyncio event loop internally.
Attributes¶
Classes¶
Bundle returned by |
|
Configuration for a gRPC server. |
Functions¶
|
Configure structlog with JSON rendering and ISO timestamps. |
|
Compute the TCP bind address. |
|
Get transport configuration from environment. |
|
Create an async gRPC server with health checking wired up. |
|
Run an async gRPC server until termination. |
|
Clean up a UDS socket file. |
|
Run a command handler gRPC server. |
|
Run a saga gRPC server. |
|
Run a process manager gRPC server. |
|
Run a projector gRPC server. |
|
Run an upcaster gRPC server. |
Module Contents¶
- angzarr_client.server.configure_logging() None¶
Configure structlog with JSON rendering and ISO timestamps.
- angzarr_client.server.ENV_BIND_ADDRESS = 'ANGZARR_BIND_ADDRESS'¶
- angzarr_client.server.DEFAULT_BIND_HOST = '[::]'¶
- angzarr_client.server.resolve_bind_address(default_port: int = 50052) str¶
Compute the TCP bind address.
Audit #77: returns
ANGZARR_BIND_ADDRESSverbatim when set, otherwise composes[::]:{port}whereportcomes from thePORTenv var ordefault_port.
- angzarr_client.server.get_transport_config() tuple[str, str]¶
Get transport configuration from environment.
- Returns:
Tuple of (transport_type, address) - For TCP: (“tcp”, “[::]:{port}”) — overridable via
ANGZARR_BIND_ADDRESSFor UDS: (“uds”, “unix://{socket_path}”)
- class angzarr_client.server.ServerHandle¶
Bundle returned by
create_server()carrying everything the runner needs to start the server, drive readiness, and shut down cleanly. Mirrors the Rustservermodule’s call sites.- server: grpc.aio.Server¶
- transport_signal: angzarr_client.readiness.TransportSignal¶
- health_servicer: grpc_health.v1.health.aio.HealthServicer¶
- angzarr_client.server.create_server(add_servicer_func: collections.abc.Callable, servicer: object, service_name: str = '') ServerHandle¶
Create an async gRPC server with health checking wired up.
Audit #68: health reporting starts at
NOT_SERVINGfor both the empty (overall) service name and any explicitservice_name; the readiness supervisor flips it once every probe passes. Pre-#68 Python setSERVINGimmediately, which made K8s readiness vacuously true.
- angzarr_client.server.run_server(add_servicer_func: collections.abc.Callable, servicer: object, service_name: str = '', domain: str = '', default_port: str = '50052', sync_output_domains: list[str] | None = None, has_async_outputs: bool = False, logger=None) None¶
Run an async gRPC server until termination.
Sync entry point — runs the asyncio event loop internally so callers can keep using the same blocking shape they had before.
- class angzarr_client.server.ServerConfig¶
Configuration for a gRPC server.
Cross-language alias for Rust’s ServerConfig { port, uds_path }.
- classmethod from_env(default_port: int = 50052) ServerConfig¶
- angzarr_client.server.run_command_handler_server(router, domain: str = '', default_port: int = 50052) None¶
Run a command handler gRPC server.
- angzarr_client.server.run_saga_server(router, domain: str = '', default_port: int = 50052) None¶
Run a saga gRPC server.
- angzarr_client.server.run_process_manager_server(router, domain: str = '', default_port: int = 50052) None¶
Run a process manager gRPC server.