pub struct MessageBus { /* private fields */ }Expand description
Message bus for agent communication
Following London School TDD:
- Agents don’t call each other directly
- All communication goes through the message bus
- Easy to mock for testing
Implementations§
Source§impl MessageBus
impl MessageBus
Sourcepub fn register(&mut self, agent_id: AgentId) -> UnboundedReceiver<Message>
pub fn register(&mut self, agent_id: AgentId) -> UnboundedReceiver<Message>
Register an agent with the message bus
Sourcepub fn unregister(&mut self, agent_id: &AgentId)
pub fn unregister(&mut self, agent_id: &AgentId)
Unregister an agent from the message bus
Sourcepub async fn broadcast(&self, message: Message) -> Result<()>
pub async fn broadcast(&self, message: Message) -> Result<()>
Broadcast a message to all registered agents
Sourcepub fn agent_count(&self) -> usize
pub fn agent_count(&self) -> usize
Get the number of registered agents
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MessageBus
impl RefUnwindSafe for MessageBus
impl Send for MessageBus
impl Sync for MessageBus
impl Unpin for MessageBus
impl UnwindSafe for MessageBus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more