Skip to main content

RuntimeBridge

Trait RuntimeBridge 

Source
pub trait RuntimeBridge<R: Reactor>: Reactor {
    // Required methods
    fn reactor(&self) -> &R;
    fn spawn_child(&self, spec: ChildSpec<R>, parent: &ActorPath) -> AddrHash;
    fn stop_self(&self);
    fn route(
        &self,
        envelope: Envelope,
        payload: MessagePayload,
    ) -> Result<(), SendError>;
    fn send_after(
        &self,
        delay: Duration,
        envelope: Envelope,
        payload: MessagePayload,
    );
    fn lookup_path(&self, path: &ActorPath) -> Option<AddrHash>;

    // Provided methods
    fn resolve_addr(&self, hash: AddrHash) -> Option<ActorPath> { ... }
    fn cached_sender(&self, addr: AddrHash) -> Option<CachedSendFn> { ... }
}
Expand description

Bridge between ActorContext methods and the runtime event loop.

Implemented by pd-runtime; injected into each actor’s context at spawn time. Uses only types defined in pd-actor to avoid a circular crate dependency.

Required Methods§

Source

fn reactor(&self) -> &R

Access the underlying reactor implementation.

Source

fn spawn_child(&self, spec: ChildSpec<R>, parent: &ActorPath) -> AddrHash

Spawn a child actor under parent’s path. Returns the child’s AddrHash (derived synchronously from the path); the runtime processes the spawn asynchronously.

Source

fn stop_self(&self)

Signal the event loop to stop this actor after the current handler returns.

Source

fn route( &self, envelope: Envelope, payload: MessagePayload, ) -> Result<(), SendError>

Route a pre-built envelope through the local transport layer.

Source

fn send_after( &self, delay: Duration, envelope: Envelope, payload: MessagePayload, )

Schedule payload to be sent at envelope.destination after delay.

Source

fn lookup_path(&self, path: &ActorPath) -> Option<AddrHash>

Resolve an actor’s current address by its path.

Provided Methods§

Source

fn resolve_addr(&self, hash: AddrHash) -> Option<ActorPath>

Resolve an actor’s path from its address hash.

Used by ActorContext::send_raw to enforce namespace policy. Returns None if the address is unknown (e.g., synthetic or external); callers fail open in that case.

Source

fn cached_sender(&self, addr: AddrHash) -> Option<CachedSendFn>

Return a direct CachedSendFn for addr if it is a local actor.

The returned closure bypasses the global TransportRegistry and sends directly to the actor’s MailboxSender. Returns None when the destination is not local (remote / federated actors).

Default implementation returns None; RuntimeBridgeImpl overrides this to perform the DashMap lookup and wrap the sender.

Implementors§