[−][src]Struct riker::actor::Context
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]
impl<Msg> Context<Msg> where
Msg: Message,
pub fn new(
myself: ActorRef<Msg>,
system: ActorSystem<Msg>,
persistence: Persistence<Msg>,
kernel: KernelRef<Msg>
) -> Context<Msg>
[src]
pub fn new(
myself: ActorRef<Msg>,
system: ActorSystem<Msg>,
persistence: Persistence<Msg>,
kernel: KernelRef<Msg>
) -> Context<Msg>
pub fn myself(&self) -> ActorRef<Msg>
[src]
pub fn myself(&self) -> ActorRef<Msg>
Returns the ActorRef
of the current actor.
pub fn persist_event(&self, evt: Msg)
[src]
pub fn persist_event(&self, evt: Msg)
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]
impl<Msg> ActorRefFactory for Context<Msg> where
Msg: Message,
type Msg = Msg
fn actor_of(
&self,
props: BoxActorProd<Self::Msg>,
name: &str
) -> Result<ActorRef<Msg>, CreateError>
[src]
fn actor_of(
&self,
props: BoxActorProd<Self::Msg>,
name: &str
) -> Result<ActorRef<Msg>, CreateError>
fn stop(&self, actor: &ActorRef<Self::Msg>)
[src]
fn stop(&self, actor: &ActorRef<Self::Msg>)
impl<Msg> TmpActorRefFactory for Context<Msg> where
Msg: Message,
[src]
impl<Msg> TmpActorRefFactory for Context<Msg> where
Msg: Message,
type Msg = Msg
fn tmp_actor_of(
&self,
props: BoxActorProd<Msg>
) -> Result<ActorRef<Msg>, CreateError>
[src]
fn tmp_actor_of(
&self,
props: BoxActorProd<Msg>
) -> Result<ActorRef<Msg>, CreateError>
impl<Msg> ActorSelectionFactory for Context<Msg> where
Msg: Message,
[src]
impl<Msg> ActorSelectionFactory for Context<Msg> where
Msg: Message,
impl<Msg> Timer for Context<Msg> where
Msg: Message,
[src]
impl<Msg> Timer for Context<Msg> where
Msg: Message,
type Msg = Msg
fn schedule<T>(
&self,
initial_delay: Duration,
interval: Duration,
receiver: ActorRef<Self::Msg>,
sender: Option<ActorRef<Self::Msg>>,
msg: T
) -> Uuid where
T: Into<ActorMsg<Self::Msg>>,
[src]
fn schedule<T>(
&self,
initial_delay: Duration,
interval: Duration,
receiver: ActorRef<Self::Msg>,
sender: Option<ActorRef<Self::Msg>>,
msg: T
) -> Uuid where
T: Into<ActorMsg<Self::Msg>>,
fn schedule_once<T>(
&self,
delay: Duration,
receiver: ActorRef<Self::Msg>,
sender: Option<ActorRef<Self::Msg>>,
msg: T
) -> Uuid where
T: Into<ActorMsg<Self::Msg>>,
[src]
fn schedule_once<T>(
&self,
delay: Duration,
receiver: ActorRef<Self::Msg>,
sender: Option<ActorRef<Self::Msg>>,
msg: T
) -> Uuid where
T: Into<ActorMsg<Self::Msg>>,
fn schedule_at_time<T>(
&self,
time: DateTime<Utc>,
receiver: ActorRef<Self::Msg>,
sender: Option<ActorRef<Self::Msg>>,
msg: T
) -> Uuid where
T: Into<ActorMsg<Self::Msg>>,
[src]
fn schedule_at_time<T>(
&self,
time: DateTime<Utc>,
receiver: ActorRef<Self::Msg>,
sender: Option<ActorRef<Self::Msg>>,
msg: T
) -> Uuid where
T: Into<ActorMsg<Self::Msg>>,
fn cancel_schedule(&self, id: Uuid)
[src]
fn cancel_schedule(&self, id: Uuid)
impl<Msg> ExecutionContext for Context<Msg> where
Msg: Message,
[src]
impl<Msg> ExecutionContext for Context<Msg> where
Msg: Message,
fn execute<F: Future>(&self, f: F) -> DispatchHandle<F::Item, F::Error> where
F: Future + Send + 'static,
F::Item: Send + 'static,
F::Error: Send + 'static,
[src]
fn execute<F: Future>(&self, f: F) -> DispatchHandle<F::Item, F::Error> where
F: Future + Send + 'static,
F::Item: Send + 'static,
F::Error: Send + 'static,
impl<'a, Msg> From<&'a ActorCell<Msg>> for Context<Msg> where
Msg: Message,
[src]
impl<'a, Msg> From<&'a ActorCell<Msg>> for Context<Msg> where
Msg: Message,
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,