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

ServerHandle

Bundle returned by create_server() carrying everything the

ServerConfig

Configuration for a gRPC server.

Functions

configure_logging(→ None)

Configure structlog with JSON rendering and ISO timestamps.

resolve_bind_address(→ str)

Compute the TCP bind address.

get_transport_config(→ tuple[str, str])

Get transport configuration from environment.

create_server(→ ServerHandle)

Create an async gRPC server with health checking wired up.

run_server(→ None)

Run an async gRPC server until termination.

cleanup_socket(→ None)

Clean up a UDS socket file.

run_command_handler_server(→ None)

Run a command handler gRPC server.

run_saga_server(→ None)

Run a saga gRPC server.

run_process_manager_server(→ None)

Run a process manager gRPC server.

run_projector_server(→ None)

Run a projector gRPC server.

run_upcaster_server(→ None)

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_ADDRESS verbatim when set, otherwise composes [::]:{port} where port comes from the PORT env var or default_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_ADDRESS

  • For 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 Rust server module’s call sites.

server: grpc.aio.Server
address: str
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_SERVING for both the empty (overall) service name and any explicit service_name; the readiness supervisor flips it once every probe passes. Pre-#68 Python set SERVING immediately, 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.

angzarr_client.server.cleanup_socket(socket_path: str) None

Clean up a UDS socket file.

class angzarr_client.server.ServerConfig

Configuration for a gRPC server.

Cross-language alias for Rust’s ServerConfig { port, uds_path }.

port: int = 50052
uds_path: str | None = None
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.

angzarr_client.server.run_projector_server(router, domain: str = '', default_port: int = 50052) None

Run a projector gRPC server.

angzarr_client.server.run_upcaster_server(router, domain: str = '', default_port: int = 50052) None

Run an upcaster gRPC server.