AgentSpawner

Trait AgentSpawner 

Source
pub trait AgentSpawner: Send + Sync {
    // Required methods
    fn spawn_agent<'life0, 'async_trait>(
        &'life0 self,
        id: String,
        name: String,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn send_event<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
        payload: String,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn load_state<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn shutdown_all<'life0, 'async_trait>(
        &'life0 self,
        grace_secs: u64,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided method
    fn spawn_agent_with_request<'life0, 'async_trait>(
        &'life0 self,
        request: AgentSpawnRequest,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

Trait for spawning and managing isolated agents

Required Methods§

Source

fn spawn_agent<'life0, 'async_trait>( &'life0 self, id: String, name: String, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Spawn an agent and return its id

Source

fn send_event<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, payload: String, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Send an event envelope to a running agent

Source

fn load_state<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Attempt to restore state for an agent

Source

fn shutdown_all<'life0, 'async_trait>( &'life0 self, grace_secs: u64, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Shutdown all agents with a grace period

Provided Methods§

Source

fn spawn_agent_with_request<'life0, 'async_trait>( &'life0 self, request: AgentSpawnRequest, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Spawn an agent with an explicit request payload.

Implementors§