pub struct AsyncAggregatorAgent { /* private fields */ }Expand description
An agent that aggregates events by correlation ID.
This agent waits for all specified event types to arrive for a given correlation ID before processing them together. This is useful for workflows where multiple independent operations must complete before a final action can be taken.
§Examples
ⓘ
use mojentic::agents::AsyncAggregatorAgent;
use std::any::TypeId;
let agent = AsyncAggregatorAgent::new(vec![
TypeId::of::<Event1>(),
TypeId::of::<Event2>(),
]);Implementations§
Source§impl AsyncAggregatorAgent
impl AsyncAggregatorAgent
Sourcepub fn new(event_types_needed: Vec<TypeId>) -> Self
pub fn new(event_types_needed: Vec<TypeId>) -> Self
Create a new AsyncAggregatorAgent.
§Arguments
event_types_needed- Vector of TypeIds representing the event types that must be collected before processing
Sourcepub async fn wait_for_events(
&self,
correlation_id: &str,
timeout: Option<Duration>,
) -> Result<Vec<Box<dyn Event>>>
pub async fn wait_for_events( &self, correlation_id: &str, timeout: Option<Duration>, ) -> Result<Vec<Box<dyn Event>>>
Wait for all needed events for a specific correlation ID.
This method blocks until all required event types have been received for the given correlation ID, or until the timeout expires.
§Arguments
correlation_id- The correlation ID to wait fortimeout- Optional timeout duration
§Returns
Vector of all events collected for this correlation ID
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AsyncAggregatorAgent
impl !RefUnwindSafe for AsyncAggregatorAgent
impl Send for AsyncAggregatorAgent
impl Sync for AsyncAggregatorAgent
impl Unpin for AsyncAggregatorAgent
impl !UnwindSafe for AsyncAggregatorAgent
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