pub struct MessageRouter { /* private fields */ }Expand description
The messaging router handles delivery of inter-agent messages.
Implementations§
Source§impl MessageRouter
impl MessageRouter
Sourcepub fn register(&self, fighter_id: FighterId) -> Receiver<AgentMessage>
pub fn register(&self, fighter_id: FighterId) -> Receiver<AgentMessage>
Register a fighter’s mailbox. Returns a receiver for the fighter to consume messages from.
Sourcepub fn unregister(&self, fighter_id: &FighterId)
pub fn unregister(&self, fighter_id: &FighterId)
Unregister a fighter’s mailbox.
Sourcepub fn is_registered(&self, fighter_id: &FighterId) -> bool
pub fn is_registered(&self, fighter_id: &FighterId) -> bool
Check if a fighter has a registered mailbox.
Sourcepub async fn send_direct(
&self,
from: FighterId,
to: FighterId,
content: AgentMessageType,
priority: MessagePriority,
) -> PunchResult<Uuid>
pub async fn send_direct( &self, from: FighterId, to: FighterId, content: AgentMessageType, priority: MessagePriority, ) -> PunchResult<Uuid>
Send a direct message from one fighter to another.
Sourcepub async fn broadcast(
&self,
from: FighterId,
content: AgentMessageType,
priority: MessagePriority,
) -> PunchResult<Vec<Uuid>>
pub async fn broadcast( &self, from: FighterId, content: AgentMessageType, priority: MessagePriority, ) -> PunchResult<Vec<Uuid>>
Broadcast a message to all registered fighters (except the sender).
Sourcepub async fn multicast(
&self,
from: FighterId,
targets: Vec<FighterId>,
content: AgentMessageType,
priority: MessagePriority,
) -> PunchResult<Vec<Uuid>>
pub async fn multicast( &self, from: FighterId, targets: Vec<FighterId>, content: AgentMessageType, priority: MessagePriority, ) -> PunchResult<Vec<Uuid>>
Multicast a message to a specific set of fighters.
Sourcepub async fn request(
&self,
from: FighterId,
to: FighterId,
content: AgentMessageType,
timeout: Duration,
) -> PunchResult<AgentMessage>
pub async fn request( &self, from: FighterId, to: FighterId, content: AgentMessageType, timeout: Duration, ) -> PunchResult<AgentMessage>
Send a request and wait for a response with timeout.
Returns the response message on success, or a timeout error.
Sourcepub fn respond(
&self,
original_msg_id: &Uuid,
response: AgentMessage,
) -> PunchResult<()>
pub fn respond( &self, original_msg_id: &Uuid, response: AgentMessage, ) -> PunchResult<()>
Respond to a request message.
Sourcepub fn dead_letter_count(&self) -> usize
pub fn dead_letter_count(&self) -> usize
Get the count of dead letters.
Sourcepub fn drain_dead_letters(&self) -> Vec<AgentMessage>
pub fn drain_dead_letters(&self) -> Vec<AgentMessage>
Drain all dead letters.
Sourcepub fn registered_count(&self) -> usize
pub fn registered_count(&self) -> usize
Get the number of registered mailboxes.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MessageRouter
impl !RefUnwindSafe for MessageRouter
impl Send for MessageRouter
impl Sync for MessageRouter
impl Unpin for MessageRouter
impl UnsafeUnpin for MessageRouter
impl !UnwindSafe for MessageRouter
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more