BroadcastQueue Class
A queue for broadcasting messages to listeners.
Note: This class is marked as 'experimental' and may change in the future.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Constructor
BroadcastQueue(*, queues: dict[str, QueueReference] = None, block_duration: float = 0.1)
Keyword-Only Parameters
| Name | Description |
|---|---|
|
queues
Required
|
|
|
block_duration
|
Default value: 0.1
|
Methods
| enqueue |
Enqueue a set of messages for a given channel. |
| ensure_synchronized |
Blocks until a channel-queue is not in a receive state to ensure that channel history is complete. |
| receive |
Processes the specified queue with the provided channel, until the queue is empty. |
enqueue
Enqueue a set of messages for a given channel.
async enqueue(channel_refs: list[ChannelReference], messages: list[ChatMessageContent]) -> None
Parameters
| Name | Description |
|---|---|
|
channel_refs
Required
|
The channel references. |
|
messages
Required
|
The messages to broadcast. |
ensure_synchronized
Blocks until a channel-queue is not in a receive state to ensure that channel history is complete.
async ensure_synchronized(channel_ref: ChannelReference) -> None
Parameters
| Name | Description |
|---|---|
|
channel_ref
Required
|
The channel reference. |
receive
Processes the specified queue with the provided channel, until the queue is empty.
async receive(channel_ref: ChannelReference, queue_ref: QueueReference) -> None
Parameters
| Name | Description |
|---|---|
|
channel_ref
Required
|
The channel reference. |
|
queue_ref
Required
|
The queue reference. |
Attributes
block_duration
block_duration: float
is_experimental
is_experimental = True
queues
queues: dict[str, QueueReference]
stage_status
stage_status = 'experimental'