Mailbox¶
casty.Mailbox
¶
Async message queue for actor message delivery.
Wraps an asyncio.Queue with configurable capacity and overflow
handling. When no capacity is set the mailbox is unbounded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capacity
|
int | None
|
Maximum number of messages. |
None
|
overflow
|
MailboxOverflowStrategy
|
Policy when the mailbox is full. |
drop_new
|
Examples:
>>> from casty import Mailbox, MailboxOverflowStrategy
>>> mb = Mailbox[str](capacity=10, overflow=MailboxOverflowStrategy.drop_new)
__init__(capacity=None, overflow=MailboxOverflowStrategy.drop_new)
¶
put(msg)
¶
Enqueue a message, applying the overflow strategy if full.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg
|
M
|
The message to enqueue. |
required |
Raises:
| Type | Description |
|---|---|
QueueFull
|
When the overflow strategy is |
Examples: