grpc_server_manager
drunc.grpc_testing_tools.grpc_server_manager
gRPC Server Manager
Provides unified server lifecycle management across different process execution methods (multiprocessing, SSH, etc.). Delegates process creation and execution to connection managers while handling server-specific configuration and coordination.
Classes
GrpcServerManager(connection_manager)
Manager for gRPC server lifecycle across different execution environments.
Provides unified interface for starting, stopping, and monitoring gRPC servers regardless of underlying process execution method (multiprocessing, SSH, etc.). Delegates actual process creation and management to connection managers while providing server-specific configuration and function references.
Initialise gRPC server manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connection_manager
|
ProcessConnectionManager
|
Process execution manager (e.g., multiprocessing or SSH) |
required |
Source code in drunc/grpc_testing_tools/grpc_server_manager.py
Functions
cleanup()
Clean up all resources and stop remaining servers.
Stops all managed servers and delegates cleanup to the connection manager for any implementation-specific resource cleanup.
Source code in drunc/grpc_testing_tools/grpc_server_manager.py
get_server_handle(server_id)
Get process handle for a managed server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_id
|
str
|
ID of the server |
required |
Returns:
| Type | Description |
|---|---|
Optional[RunningGrpcServer]
|
RunningGrpcServer handle if server exists, None otherwise |
Source code in drunc/grpc_testing_tools/grpc_server_manager.py
get_server_handles()
Get all server handles managed by this instance.
Returns:
| Type | Description |
|---|---|
Dict[str, RunningGrpcServer]
|
Dictionary mapping server IDs to their RunningGrpcServer handles |
Source code in drunc/grpc_testing_tools/grpc_server_manager.py
is_server_running(server_id)
Check if a gRPC server is currently running and accepting connections.
Uses gRPC channel readiness checking to determine if the server is operational. This is implementation-agnostic and works regardless of how the server process was started.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_id
|
str
|
ID of the server to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if server is running and channel is ready, False otherwise |
Source code in drunc/grpc_testing_tools/grpc_server_manager.py
start_child_controller_server(config)
Start a ChildController gRPC server.
Creates and starts a ChildController server process. ChildControllers are leaf nodes that handle specific tasks and report to the RootController.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
GrpcServerConfig
|
Configuration for the ChildController server (must include root_port and child_name) |
required |
Returns:
| Type | Description |
|---|---|
RunningGrpcServer
|
RunningGrpcServer handle for the started server |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If server cannot be started |
Source code in drunc/grpc_testing_tools/grpc_server_manager.py
start_manager_server(config, lifetime_manager_type=ProcessManagerTypes.SSH_PARAMIKO)
Start a Manager gRPC server.
Creates and starts a Manager server process using the configured connection manager. The Manager is the top-level coordinator in the system hierarchy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
GrpcServerConfig
|
Configuration for the Manager server |
required |
Returns:
| Type | Description |
|---|---|
RunningGrpcServer
|
RunningGrpcServer handle for the started server |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If server cannot be started |
Source code in drunc/grpc_testing_tools/grpc_server_manager.py
start_root_controller_server(config)
Start a RootController gRPC server.
Creates and starts a RootController server process. The RootController acts as an intermediate coordinator between the Manager and ChildControllers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
GrpcServerConfig
|
Configuration for the RootController server (must include manager_port) |
required |
Returns:
| Type | Description |
|---|---|
RunningGrpcServer
|
RunningGrpcServer handle for the started server |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If server cannot be started |
Source code in drunc/grpc_testing_tools/grpc_server_manager.py
stop_all_servers(timeout=10.0)
Stop all managed gRPC servers.
Iterates through all tracked servers and stops them gracefully. Continues attempting to stop remaining servers even if individual stops fail.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
Maximum time to wait for each server to stop |
10.0
|
Source code in drunc/grpc_testing_tools/grpc_server_manager.py
stop_server(server_id, timeout=10.0)
Stop a running gRPC server gracefully.
Delegates to the connection manager for actual process termination, handling any implementation-specific shutdown procedures (e.g., signalling stop events for multiprocessing, terminating SSH connections).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_id
|
str
|
ID of the server to stop |
required |
timeout
|
float
|
Maximum time to wait for graceful shutdown |
10.0
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If server cannot be stopped |
Source code in drunc/grpc_testing_tools/grpc_server_manager.py
wait_for_server_ready(server_id, timeout=10.0)
Wait for a server to become ready and accept connections.
Polls the server's gRPC port to determine when it's ready to handle requests. This method is implementation-agnostic and works regardless of how the server process was started.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_id
|
str
|
ID of the server to wait for |
required |
timeout
|
float
|
Maximum time to wait in seconds |
10.0
|
Returns:
| Type | Description |
|---|---|
bool
|
True if server is ready and accepting connections, False if timeout occurs |