pub struct AgentRuntime(/* private fields */);Expand description
Represents a ready state of the Acton system.
This struct encapsulates the internal state of the Acton system when it’s ready for use. It provides methods for creating and managing actors within the system.
Implementations§
Source§impl AgentRuntime
impl AgentRuntime
Sourcepub async fn new_agent_with_name<State>(
&mut self,
name: String,
) -> ManagedAgent<Idle, State>
pub async fn new_agent_with_name<State>( &mut self, name: String, ) -> ManagedAgent<Idle, State>
Sourcepub async fn new_agent<State>(&mut self) -> ManagedAgent<Idle, State>
pub async fn new_agent<State>(&mut self) -> ManagedAgent<Idle, State>
Sourcepub fn agent_count(&self) -> usize
pub fn agent_count(&self) -> usize
Retrieves the number of actors currently running in the system.
Sourcepub async fn create_actor_with_config<State>(
&mut self,
config: AgentConfig,
) -> ManagedAgent<Idle, State>
pub async fn create_actor_with_config<State>( &mut self, config: AgentConfig, ) -> ManagedAgent<Idle, State>
Creates a new actor with a specified configuration.
§Type Parameters
State- The state type of the actor, which must implementDefault,Send,Debug, and have a static lifetime.
§Arguments
config- TheActorConfigto use for creating the actor.
§Returns
A ManagedActor in the Idle state with the specified State and configuration.
Sourcepub fn broker(&self) -> AgentHandle
pub fn broker(&self) -> AgentHandle
Retrieves the broker reference for the system.
§Returns
A clone of the BrokerRef associated with this SystemReady instance.
Sourcepub async fn spawn_agent_with_setup_fn<State>(
&mut self,
config: AgentConfig,
setup_fn: impl FnOnce(ManagedAgent<Idle, State>) -> Pin<Box<dyn Future<Output = AgentHandle> + Send + 'static>>,
) -> Result<AgentHandle>
pub async fn spawn_agent_with_setup_fn<State>( &mut self, config: AgentConfig, setup_fn: impl FnOnce(ManagedAgent<Idle, State>) -> Pin<Box<dyn Future<Output = AgentHandle> + Send + 'static>>, ) -> Result<AgentHandle>
Spawns an actor with a custom setup function and configuration.
§Type Parameters
State- The state type of the actor, which must implementDefault,Send,Debug, and have a static lifetime.
§Arguments
config- TheActorConfigto use for creating the actor.setup_fn- A function that takes aManagedActorand returns aFutureresolving to anActorRef.
§Returns
A Result containing the ActorRef of the spawned actor, or an error if the spawn failed.
Sourcepub async fn shutdown_all(&mut self) -> Result<()>
pub async fn shutdown_all(&mut self) -> Result<()>
Shuts down the Acton system, stopping all actors and their children.
Sourcepub async fn spawn_actor<State>(
&mut self,
setup_fn: impl FnOnce(ManagedAgent<Idle, State>) -> Pin<Box<dyn Future<Output = AgentHandle> + Send + 'static>>,
) -> Result<AgentHandle>
pub async fn spawn_actor<State>( &mut self, setup_fn: impl FnOnce(ManagedAgent<Idle, State>) -> Pin<Box<dyn Future<Output = AgentHandle> + Send + 'static>>, ) -> Result<AgentHandle>
Spawns an actor with a custom setup function and default configuration.
§Type Parameters
State- The state type of the actor, which must implementDefault,Send,Debug, and have a static lifetime.
§Arguments
setup_fn- A function that takes aManagedActorand returns aFutureresolving to anActorRef.
§Returns
A Result containing the ActorRef of the spawned actor, or an error if the spawn failed.
Trait Implementations§
Source§impl Clone for AgentRuntime
impl Clone for AgentRuntime
Source§fn clone(&self) -> AgentRuntime
fn clone(&self) -> AgentRuntime
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more