pub struct ActorSystem {
pub blocking: bool,
/* private fields */
}Expand description
The ActorSystem is the main entry point for managing actors. It contains a handler channel to send commands to the actor system. It’s clonable so that it can be shared across different parts of the application.
Fields§
§blocking: boolImplementations§
Source§impl ActorSystem
impl ActorSystem
Sourcepub fn handler_tx(&self) -> UnboundedSender<ActorSystemCmd>
pub fn handler_tx(&self) -> UnboundedSender<ActorSystemCmd>
Returns the handler channel sender for the ActorSystem. You can use this to send commands to the ActorSystem directly.
Sourcepub async fn filter_address(&mut self, address_regex: String) -> Vec<String>
pub async fn filter_address(&mut self, address_regex: String) -> Vec<String>
Filters the addresses of actors based on a regex pattern.
Sourcepub fn unregister(&mut self, address_regex: String)
pub fn unregister(&mut self, address_regex: String)
Registers an actor.
Sourcepub async fn send<T>(
&self,
address: String,
msg: <T as Actor>::Message,
) -> Result<(), ActorError>where
T: Actor,
pub async fn send<T>(
&self,
address: String,
msg: <T as Actor>::Message,
) -> Result<(), ActorError>where
T: Actor,
Send a message to a specific actor by its address. It doesn’t wait for the actor to be ready.
Sourcepub async fn send_broadcast<T>(
&self,
address_regex: String,
msg: <T as Actor>::Message,
) -> Vec<Result<(), ActorError>>where
T: Actor,
pub async fn send_broadcast<T>(
&self,
address_regex: String,
msg: <T as Actor>::Message,
) -> Vec<Result<(), ActorError>>where
T: Actor,
Sends a message to all actors that match the given address regex. It returns a vector of results, success or error for each actor. It doesn’t returns results from the actors, only whether the message was sent successfully or not.
Sourcepub async fn send_and_recv<T>(
&self,
address: String,
msg: <T as Actor>::Message,
) -> Result<<T as Actor>::Result, ActorError>where
T: Actor,
pub async fn send_and_recv<T>(
&self,
address: String,
msg: <T as Actor>::Message,
) -> Result<<T as Actor>::Result, ActorError>where
T: Actor,
Sends a message to a specific actor and waits for the result.
Sourcepub async fn run_job<T>(
&self,
address: String,
subscribe: bool,
job: JobSpec,
msg: <T as Actor>::Message,
) -> Result<Option<UnboundedReceiver<Result<<T as Actor>::Result, Error>>>, ActorError>where
T: Actor,
pub async fn run_job<T>(
&self,
address: String,
subscribe: bool,
job: JobSpec,
msg: <T as Actor>::Message,
) -> Result<Option<UnboundedReceiver<Result<<T as Actor>::Result, Error>>>, ActorError>where
T: Actor,
Runs a job with the specified actor and message.
If you want to subscribe to the results, set subscribe to true.
It returns a receiver that you can use to receive the results.
Trait Implementations§
Source§impl Clone for ActorSystem
impl Clone for ActorSystem
Source§fn clone(&self) -> ActorSystem
fn clone(&self) -> ActorSystem
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more