/// Invokes each registered agent for a given lifespan. If sequential is true,
/// invocations will only proceed to the next agent once the current
/// invocation has been successfully acknowledged. When sequential is false,
/// agents will receive their invocations without waiting. However, the
/// overall completion (signaled through the receiver returned by the method),
/// will not return until all invocations have been acknowledged.
Invokes each registered agent for a given lifespan. If sequential is true,
invocations will only proceed to the next agent once the current
invocation has been successfully acknowledged. When sequential is false,
agents will receive their invocations without waiting. However, the
overall completion (signaled through the receiver returned by the method),
will not return until all invocations have been acknowledged.
Invokes each registered agent for a given lifespan . If sequential is true invocations will only proceed to the next agent once the current invocation has been successfully acknowledged . When sequential is false agents will receive their invocations without waiting . However the overall completion ( signaled through the receiver returned by the method ) will not return until all invocations have been acknowledged .
pub async fn execute_lifespan(
        &self,
        lifespan: Lifespan,
        service_context: Arc<ServiceContext>,
        sequential: bool,
    ) -> Result<(), Error> {
        let mut pending_receptors = Vec::new();
        for &signature in &self.agent_signatures {
            let mut receptor = self
                .messenger
                .message(
                    Payload::Invocation(Invocation {
                        lifespan,
                        service_context: Arc::clone(&service_context),
                    })
                    .into(),
                    Audience::Messenger(signature),
                )
                .send();
            if sequential {
                let result = process_payload(receptor.next_of::<Payload>().await);
                if result.is_err() {
                    return result;
                }
            } else {
                pending_receptors.push(receptor);
            }
        }
        // Pending acks should only be present for non sequential execution. In
        // this case wait for each to complete.
        for mut receptor in pending_receptors {
            let result = process_payload(receptor.next_of::<Payload>().await);
            if result.is_err() {
                return result;
            }
        }
        Ok(())
    }
pub async fn execute_lifespan ( & self , lifespan : Lifespan , service_context : Arc < ServiceContext > , sequential : bool , ) -> Result < ( ) , Error > { let mut pending_receptors = Vec :: new ( ) ; for & signature in & self . agent_signatures { let mut receptor = self . messenger . message ( Payload :: Invocation ( Invocation { lifespan , service_context : Arc :: clone ( & service_context ) , } ) . into ( ) , Audience :: Messenger ( signature ) , ) . send ( ) ; if sequential { let result = process_payload ( receptor . next_of :: < Payload > ( ) . await ) ; if result . is_err ( ) { return result ; } } else { pending_receptors . push ( receptor ) ; } } // Pending acks should only be present for non sequential execution. In // this case wait for each to complete. for mut receptor in pending_receptors { let result = process_payload ( receptor . next_of :: < Payload > ( ) . await ) ; if result . is_err ( ) { return result ; } } Ok ( ( ) ) }
Invokes each registered agent for a given lifespan.
Invokes each registered agent for a given lifespan .
&self
lifespan
Lifespan
service_context
Arc<ServiceContext>
sequential
bool