RabbitMQ Client Reference¶
rabbitmq_client
¶
RabbitMQ async client for puzzle job queuing.
init_rabbitmq
async
¶
Initialize RabbitMQ connection and declare queue.
Source code in src/clients/rabbitmq_client.py
close_rabbitmq
async
¶
Close RabbitMQ connection.
Raises:
| Type | Description |
|---|---|
Exception
|
If closing the connection fails. |
Source code in src/clients/rabbitmq_client.py
enqueue_problem
async
¶
Publish a Problem instance to the queue using msgpack serialization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Problem
|
The Problem instance to enqueue. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If channel is not initialized. |
Exception
|
If publishing fails. |
Source code in src/clients/rabbitmq_client.py
rabbitmq_sync_client
¶
Synchronous RabbitMQ client for solver workers.
create_rabbitmq_connection
¶
Create a new blocking RabbitMQ connection.
Returns:
| Type | Description |
|---|---|
BlockingConnection
|
pika.BlockingConnection: A new connection to RabbitMQ. |
Raises:
| Type | Description |
|---|---|
Exception
|
If connection fails. |
Source code in src/clients/rabbitmq_sync_client.py
create_rabbitmq_channel
¶
create_rabbitmq_channel(
connection: BlockingConnection,
) -> pika.adapters.blocking_connection.BlockingChannel
Create a channel from an existing RabbitMQ connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connection
|
BlockingConnection
|
An active RabbitMQ connection. |
required |
Returns:
| Type | Description |
|---|---|
BlockingChannel
|
pika.adapters.blocking_connection.BlockingChannel: A new channel. |
Raises:
| Type | Description |
|---|---|
Exception
|
If channel creation fails. |
Source code in src/clients/rabbitmq_sync_client.py
setup_consumer_channel
¶
Configure a channel for consuming messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
BlockingChannel
|
The channel to configure. |
required |
prefetch_count
|
int
|
Number of messages to prefetch (default: 1 for fair dispatch). |
1
|
Source code in src/clients/rabbitmq_sync_client.py
close_rabbitmq_connection
¶
close_rabbitmq_connection(
connection: Optional[BlockingConnection],
channel: Optional[BlockingChannel] = None,
) -> None
Safely close RabbitMQ channel and connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connection
|
Optional[BlockingConnection]
|
The connection to close. |
required |
channel
|
Optional[BlockingChannel]
|
Optional channel to close first. |
None
|