Struct ActorSystem

Source
pub struct ActorSystem {
    pub exec: ThreadPool,
    pub timer: Sender<Job>,
    pub sys_channels: Option<SysChannels>,
    /* private fields */
}
Expand description

The actor runtime and common services coordinator

The ActorSystem provides a runtime on which actors are executed. It also provides common services such as channels, persistence and scheduling. The ActorSystem is the heart of a Riker application, starting serveral threads when it is created. Create only one instance of ActorSystem per application.

Fields§

§exec: ThreadPool§timer: Sender<Job>§sys_channels: Option<SysChannels>

Implementations§

Source§

impl ActorSystem

Source

pub fn new() -> Result<Self, SystemError>

Create a new ActorSystem instance

Requires a type that implements the Model trait.

Source

pub fn with_name(name: &str) -> Result<Self, SystemError>

Create a new ActorSystem instance with provided name

Requires a type that implements the Model trait.

Source

pub fn with_config(name: &str, cfg: &Config) -> Result<Self, SystemError>

Create a new ActorSystem instance bypassing default config behavior

Source

pub fn uptime(&self) -> u64

Returns the number of seconds since the system started

Source

pub fn host(&self) -> Arc<String>

Returns the hostname used when the system started

The host is used in actor addressing.

Currently not used, but will be once system clustering is introduced.

Source

pub fn id(&self) -> Uuid

Returns the UUID assigned to the system

Source

pub fn name(&self) -> String

Returns the name of the system

Source

pub fn print_tree(&self)

Source

pub fn get_tree(&self) -> String

Source

pub fn user_root(&self) -> &BasicActorRef

Returns the system root’s actor reference Returns the user root actor reference

Source

pub fn sys_root(&self) -> &BasicActorRef

Returns the system root actor reference

Source

pub fn temp_root(&self) -> &BasicActorRef

Reutrns the temp root actor reference

Source

pub fn sys_events(&self) -> &ActorRef<ChannelMsg<SystemEvent>>

Returns a reference to the system events channel

Source

pub fn dead_letters(&self) -> &ActorRef<DLChannelMsg>

Returns a reference to the dead letters channel

Source

pub fn publish_event(&self, evt: SystemEvent)

Source

pub fn config(&self) -> Config

Returns the Config used by the system

Source

pub fn sys_actor_of_props<A>( &self, props: BoxActorProd<A>, name: &str, ) -> Result<ActorRef<A::Msg>, CreateError>
where A: Actor,

Create an actor under the system root

Source

pub fn sys_actor_of<A>( &self, name: &str, ) -> Result<ActorRef<<A as Actor>::Msg>, CreateError>
where A: ActorFactory,

Source

pub fn sys_actor_of_args<A, Args>( &self, name: &str, args: Args, ) -> Result<ActorRef<<A as Actor>::Msg>, CreateError>
where Args: ActorArgs, A: ActorFactoryArgs<Args>,

Source

pub fn log(&self) -> Logger

Source

pub fn when_terminated(&self) -> Terminated

Returns a future which is completed when all actors have successfully stopped.

Note! In the current implementation the future will not complete if root actor is already terminated.

Source

pub fn shutdown(&self) -> Shutdown

Shutdown the actor system

Attempts a graceful shutdown of the system and all actors. Actors will receive a stop message, executing actor.post_stop.

Does not block. Returns a future which is completed when all actors have successfully stopped.

Trait Implementations§

Source§

impl ActorRefFactory for ActorSystem

Source§

fn actor_of_props<A>( &self, props: BoxActorProd<A>, name: &str, ) -> Result<ActorRef<A::Msg>, CreateError>
where A: Actor,

Source§

fn actor_of<A>( &self, name: &str, ) -> Result<ActorRef<<A as Actor>::Msg>, CreateError>
where A: ActorFactory,

Source§

fn actor_of_args<A, Args>( &self, name: &str, args: Args, ) -> Result<ActorRef<<A as Actor>::Msg>, CreateError>
where Args: ActorArgs, A: ActorFactoryArgs<Args>,

Source§

fn stop(&self, actor: impl ActorReference)

Source§

impl ActorSelectionFactory for ActorSystem

Source§

fn select(&self, path: &str) -> Result<ActorSelection, InvalidPath>

Source§

impl Clone for ActorSystem

Source§

fn clone(&self) -> ActorSystem

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ActorSystem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ActorSystem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Run for ActorSystem

Source§

fn run<Fut>( &self, future: Fut, ) -> Result<RemoteHandle<<Fut as Future>::Output>, SpawnError>
where Fut: Future + Send + 'static, <Fut as Future>::Output: Send,

Source§

impl Timer for ActorSystem

Source§

fn schedule<T, M>( &self, initial_delay: Duration, interval: Duration, receiver: ActorRef<M>, sender: Sender, msg: T, ) -> Uuid
where T: Message + Into<M>, M: Message,

Source§

fn schedule_once<T, M>( &self, delay: Duration, receiver: ActorRef<M>, sender: Sender, msg: T, ) -> Uuid
where T: Message + Into<M>, M: Message,

Source§

fn schedule_at_time<T, M>( &self, time: DateTime<Utc>, receiver: ActorRef<M>, sender: Sender, msg: T, ) -> Uuid
where T: Message + Into<M>, M: Message,

Source§

fn cancel_schedule(&self, id: Uuid)

Source§

impl TmpActorRefFactory for ActorSystem

Source§

fn tmp_actor_of_props<A>( &self, props: BoxActorProd<A>, ) -> Result<ActorRef<A::Msg>, CreateError>
where A: Actor,

Source§

fn tmp_actor_of<A>(&self) -> Result<ActorRef<<A as Actor>::Msg>, CreateError>
where A: ActorFactory,

Source§

fn tmp_actor_of_args<A, Args>( &self, args: Args, ) -> Result<ActorRef<<A as Actor>::Msg>, CreateError>
where Args: ActorArgs, A: ActorFactoryArgs<Args>,

Source§

impl Send for ActorSystem

Source§

impl Sync for ActorSystem

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ActorArgs for T
where T: Clone + Send + Sync + 'static,

Source§

impl<T> Message for T
where T: Debug + Clone + Send + 'static,