[][src]Struct riker::actor::Context

pub struct Context<Msg: Message> {
    pub myself: ActorRef<Msg>,
    pub system: ActorSystem<Msg>,
    pub persistence: Persistence<Msg>,
    // some fields omitted
}

Provides context, including the actor system during actor execution.

Context is passed to an actor's functions, such as receive.

Operations performed are in most cases done so from the actor's perspective. For example, creating a child actor using ctx.actor_of will create the child under the current actor within the heirarchy. In a similar manner, persistence operations such as persist_event use the current actor's persistence configuration.

Since Context is specific to an actor and its functions it is not cloneable.

Fields

myself: ActorRef<Msg>system: ActorSystem<Msg>persistence: Persistence<Msg>

Methods

impl<Msg> Context<Msg> where
    Msg: Message
[src]

pub fn new(
    myself: ActorRef<Msg>,
    system: ActorSystem<Msg>,
    persistence: Persistence<Msg>,
    kernel: KernelRef<Msg>
) -> Context<Msg>
[src]

pub fn myself(&self) -> ActorRef<Msg>
[src]

Returns the ActorRef of the current actor.

pub fn persist_event(&self, evt: Msg)
[src]

Persists an event to the event store.

In an event sourcing environment state is maintained by storing the events that change the state. persist_event attempts to store the event.

State should not be modified until the event has been successfully persisted. The event store manager notifies the actor after each event is stored and the actor's state can then safely be updated. The actor's apply_event method is called after an event is stored.

While an event is persisting it is guaranteed that no other messages are processed until persistence is complete. I.e., no messages are processed between persist_event and the resulting apply_event.

When an actor starts (or restarts), if pesistence is configured the system will query the event source manager to get all the events for the actor. Each event is then replayed, in their original order, which effectively results in an actor being in the latest state.

Trait Implementations

impl<Msg> ActorRefFactory for Context<Msg> where
    Msg: Message
[src]

type Msg = Msg

impl<Msg> TmpActorRefFactory for Context<Msg> where
    Msg: Message
[src]

type Msg = Msg

impl<Msg> ActorSelectionFactory for Context<Msg> where
    Msg: Message
[src]

type Msg = Msg

impl<Msg> Timer for Context<Msg> where
    Msg: Message
[src]

type Msg = Msg

impl<Msg> ExecutionContext for Context<Msg> where
    Msg: Message
[src]

impl<'a, Msg> From<&'a ActorCell<Msg>> for Context<Msg> where
    Msg: Message
[src]

Auto Trait Implementations

impl<Msg> Send for Context<Msg>

impl<Msg> Sync for Context<Msg>

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]