pub struct Proc { /* private fields */ }
Expand description
A proc instance is the runtime managing a single proc in Hyperactor. It is responsible for spawning actors in the proc, multiplexing messages to/within actors in the proc, and providing fallback routing to external procs.
Procs are also responsible for maintaining the local supervision hierarchy.
Implementations§
Source§impl Proc
impl Proc
Sourcepub fn new(proc_id: ProcId, forwarder: BoxedMailboxSender) -> Self
pub fn new(proc_id: ProcId, forwarder: BoxedMailboxSender) -> Self
Create a new proc with the given proc id and forwarder.
Sourcepub fn new_with_clock(
proc_id: ProcId,
forwarder: BoxedMailboxSender,
clock: ClockKind,
) -> Self
pub fn new_with_clock( proc_id: ProcId, forwarder: BoxedMailboxSender, clock: ClockKind, ) -> Self
Create a new proc with the given proc id, forwarder and clock kind.
Sourcepub fn set_supervision_coordinator(
&self,
port: PortHandle<ActorSupervisionEvent>,
) -> Result<(), Error>
pub fn set_supervision_coordinator( &self, port: PortHandle<ActorSupervisionEvent>, ) -> Result<(), Error>
Set the supervision coordinator’s port for this proc. Return Err if it is already set.
Sourcepub fn local() -> Self
pub fn local() -> Self
Create a new local-only proc. This proc is not allowed to forward messages outside of the proc itself.
Sourcepub fn forwarder(&self) -> &BoxedMailboxSender
pub fn forwarder(&self) -> &BoxedMailboxSender
Shared sender used by the proc to forward messages to remote destinations.
Sourcepub fn ledger_snapshot(&self) -> ActorLedgerSnapshot
pub fn ledger_snapshot(&self) -> ActorLedgerSnapshot
Get the snapshot of the ledger.
Sourcepub fn attach(&self, name: &str) -> Result<Mailbox, Error>
pub fn attach(&self, name: &str) -> Result<Mailbox, Error>
Attach a mailbox to the proc with the provided root name.
Sourcepub fn attach_child(&self, parent_id: &ActorId) -> Result<Mailbox, Error>
pub fn attach_child(&self, parent_id: &ActorId) -> Result<Mailbox, Error>
Attach a mailbox to the proc as a child actor.
Sourcepub fn attach_actor<R, M>(
&self,
name: &str,
) -> Result<(Mailbox, ActorRef<R>, PortReceiver<M>), Error>
pub fn attach_actor<R, M>( &self, name: &str, ) -> Result<(Mailbox, ActorRef<R>, PortReceiver<M>), Error>
Attach a mailbox to the proc with the provided root name, and bind an ActorRef
.
This is intended only for testing, and will be replaced by simpled utilities.
Sourcepub async fn spawn<A: Actor>(
&self,
name: &str,
params: A::Params,
) -> Result<ActorHandle<A>, Error>
pub async fn spawn<A: Actor>( &self, name: &str, params: A::Params, ) -> Result<ActorHandle<A>, Error>
Spawn a named (root) actor on this proc. The name of the actor must be unique.
Sourcepub fn instance(
&self,
name: &str,
) -> Result<(Instance<()>, ActorHandle<()>), Error>
pub fn instance( &self, name: &str, ) -> Result<(Instance<()>, ActorHandle<()>), Error>
Create and return an actor instance and its corresponding handle. This allows actors to be
“inverted”: the caller can use the returned Instance
to send and receive messages,
launch child actors, etc. The actor itself does not handle any messages, and supervision events
are always forwarded to the proc. Otherwise the instance acts as a normal actor, and can be
referenced and stopped.
Sourcepub fn abort_root_actor(&self, root: &ActorId) -> Option<ActorId>
pub fn abort_root_actor(&self, root: &ActorId) -> Option<ActorId>
Call abort
on the JoinHandle
associated with the given
root actor. If successful return Some(root.clone())
else
None
.
Sourcepub fn stop_actor(&self, actor_id: &ActorId) -> Option<Receiver<ActorStatus>>
pub fn stop_actor(&self, actor_id: &ActorId) -> Option<Receiver<ActorStatus>>
Signals to a root actor to stop, returning a status observer if successful.
Sourcepub async fn destroy_and_wait(
&mut self,
timeout: Duration,
skip_waiting: Option<&ActorId>,
) -> Result<(Vec<ActorId>, Vec<ActorId>), Error>
pub async fn destroy_and_wait( &mut self, timeout: Duration, skip_waiting: Option<&ActorId>, ) -> Result<(Vec<ActorId>, Vec<ActorId>), Error>
Stop the proc. Returns a pair of:
- the actors observed to stop;
- the actors not observed to stop when timeout.
The “skip_waiting” actor, if it is Some, is always not observed to stop.
Trait Implementations§
Source§impl MailboxSender for Proc
impl MailboxSender for Proc
Source§fn post(
&self,
envelope: MessageEnvelope,
return_handle: PortHandle<Undeliverable<MessageEnvelope>>,
)
fn post( &self, envelope: MessageEnvelope, return_handle: PortHandle<Undeliverable<MessageEnvelope>>, )
Auto Trait Implementations§
impl Freeze for Proc
impl !RefUnwindSafe for Proc
impl Send for Proc
impl Sync for Proc
impl Unpin for Proc
impl !UnwindSafe for Proc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> BoxableMailboxSender for Twhere
T: MailboxSender + Clone + 'static,
impl<T> BoxableMailboxSender for Twhere
T: MailboxSender + Clone + 'static,
Source§fn boxed(&self) -> BoxedMailboxSender
fn boxed(&self) -> BoxedMailboxSender
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<A, M> Handler<IndexedErasedUnbound<M>> for A
impl<A, M> Handler<IndexedErasedUnbound<M>> for A
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoBoxedMailboxSender for Twhere
T: MailboxSender + 'static,
impl<T> IntoBoxedMailboxSender for Twhere
T: MailboxSender + 'static,
Source§fn into_boxed(self) -> BoxedMailboxSender
fn into_boxed(self) -> BoxedMailboxSender
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more