orka.startup.infrastructure package

Infrastructure Management Package

This package provides infrastructure service management for OrKa including Redis, Kafka, and health monitoring capabilities.

orka.startup.infrastructure.check_process_health(processes: Dict[str, Popen]) bool[source]

Check the health of all managed processes.

Parameters:

processes – Dictionary of process name to process object

Returns:

True if all processes are healthy, False otherwise

Return type:

bool

orka.startup.infrastructure.display_error(error: Exception) None[source]

Display error message during startup.

Parameters:

error – The exception that occurred

orka.startup.infrastructure.display_service_endpoints(backend: str) None[source]

Display service endpoints for the configured backend.

Parameters:

backend – The backend type (‘redis’, ‘redisstack’, ‘kafka’, or ‘dual’)

orka.startup.infrastructure.display_shutdown_complete() None[source]

Display shutdown complete message.

orka.startup.infrastructure.display_shutdown_message() None[source]

Display graceful shutdown message.

orka.startup.infrastructure.display_startup_success() None[source]

Display successful startup message.

async orka.startup.infrastructure.monitor_backend_process(backend_proc: Popen) None[source]

Monitor the backend process and detect if it stops unexpectedly.

Parameters:

backend_proc – The backend process to monitor

Raises:

RuntimeError – If the backend process stops unexpectedly

orka.startup.infrastructure.wait_for_services(backend: str) None[source]

Wait for infrastructure services to be ready.

Parameters:

backend – The backend type (‘redis’, ‘redisstack’, ‘kafka’, or ‘dual’)

orka.startup.infrastructure.cleanup_kafka_docker() None[source]

Clean up Kafka Docker services.

orka.startup.infrastructure.get_kafka_services() List[str][source]

Get the list of Kafka service names.

Returns:

List of Kafka service names

Return type:

List[str]

orka.startup.infrastructure.initialize_schema_registry() None[source]

Initialize schema registry by creating a temporary KafkaMemoryLogger. This ensures schemas are registered at startup time.

orka.startup.infrastructure.start_kafka_docker() None[source]

Start Kafka services using Docker Compose.

Raises:
  • subprocess.CalledProcessError – If Docker Compose commands fail

  • FileNotFoundError – If docker directory cannot be found

orka.startup.infrastructure.wait_for_kafka_services() None[source]

Wait for Kafka services to be ready and responsive.

Raises:

RuntimeError – If Kafka services fail to become ready

orka.startup.infrastructure.cleanup_redis_docker() None[source]

Clean up Redis Docker services.

orka.startup.infrastructure.start_native_redis(port: int = 6380) Popen | None[source]

Start Redis Stack natively on the specified port, with Docker fallback.

Parameters:

port – Port to start Redis on (default: 6380)

Returns:

The Redis process, or None if using Docker

Return type:

subprocess.Popen

Raises:

RuntimeError – If both native and Docker Redis fail to start

orka.startup.infrastructure.start_redis_docker(port: int = 6380) None[source]

Start Redis Stack using Docker as a fallback.

Parameters:

port – Port to start Redis on

Returns:

Docker process is managed by Docker daemon

Return type:

None

Raises:

RuntimeError – If Docker Redis fails to start

orka.startup.infrastructure.terminate_redis_process(redis_proc: Popen) None[source]

Gracefully terminate a Redis process.

Parameters:

redis_proc – The Redis process to terminate

orka.startup.infrastructure.wait_for_redis(port: int, max_attempts: int = 30) None[source]

Wait for Redis to be ready and responsive (works for both native and Docker).

Parameters:
  • port – Redis port to check

  • max_attempts – Maximum number of connection attempts

Raises:

RuntimeError – If Redis doesn’t become ready within the timeout

Submodules