pub struct DispatchConversation { /* private fields */ }Expand description
Drives conversation-mediated dispatch for one consumer group.
Each call to DispatchConversation::dispatch spawns a supervised
conversation actor (a beamr process), selects a consumer via the group’s
routing function, links the conversation to the consumer, forwards the
message, and re-routes on consumer crash.
Implementations§
Source§impl DispatchConversation
impl DispatchConversation
Sourcepub fn new(group: ConsumerGroup) -> Result<Self, DispatchError>
pub fn new(group: ConsumerGroup) -> Result<Self, DispatchError>
Creates a dispatch driver for group using a fresh conversation supervisor.
§Errors
Returns DispatchError::Conversation if the beamr scheduler backing the
conversation supervisor cannot start.
Sourcepub const fn with_supervisor(
group: ConsumerGroup,
executor: SupervisedExecutor,
supervisor: ConversationSupervisor,
) -> Self
pub const fn with_supervisor( group: ConsumerGroup, executor: SupervisedExecutor, supervisor: ConversationSupervisor, ) -> Self
Creates a dispatch driver reusing an existing conversation supervisor and supervision executor.
Sourcepub const fn group(&self) -> &ConsumerGroup
pub const fn group(&self) -> &ConsumerGroup
Returns the consumer group this dispatch conversation routes over.
Sourcepub const fn supervisor(&self) -> &ConversationSupervisor
pub const fn supervisor(&self) -> &ConversationSupervisor
Returns the conversation supervisor backing dispatch processes.
Sourcepub fn dispatch(
&self,
message: &RoutingMessage,
) -> Result<DispatchOutcome, DispatchError>
pub fn dispatch( &self, message: &RoutingMessage, ) -> Result<DispatchOutcome, DispatchError>
Dispatches message to a consumer selected by the group’s routing function.
Snapshots the group, evaluates the routing function over the live consumer state, links a dispatch conversation process to the selected consumer, forwards the message, and observes completion. On consumer crash the message is re-routed to another consumer, excluding any that have crashed.
§Errors
Returns DispatchError::NoConsumerAvailable if the routing function
selects no consumer, DispatchError::UnknownConsumerSelected if it
selects a consumer outside the group, DispatchError::Evaluation if the
supervised routing function fails, and DispatchError::Conversation if
the dispatch conversation process cannot be driven.
Trait Implementations§
Source§impl Clone for DispatchConversation
impl Clone for DispatchConversation
Source§fn clone(&self) -> DispatchConversation
fn clone(&self) -> DispatchConversation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more