Trait ProcManager

Source
pub trait ProcManager {
    type Handle: ProcHandle;

    // Required methods
    fn transport(&self) -> ChannelTransport;
    fn spawn<'life0, 'async_trait>(
        &'life0 self,
        proc_id: ProcId,
        forwarder_addr: ChannelAddr,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Handle, HostError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A trait describing a manager of procs, responsible for bootstrapping procs on a host, and managing their lifetimes. The manager spawns an Agent-typed actor on each proc, responsible for managing the proc.

Required Associated Types§

Source

type Handle: ProcHandle

Concrete handle type this manager returns.

Required Methods§

Source

fn transport(&self) -> ChannelTransport

The preferred transport for this ProcManager. In practice this will be ChannelTransport::Local for testing, and ChannelTransport::Unix for external processes.

Source

fn spawn<'life0, 'async_trait>( &'life0 self, proc_id: ProcId, forwarder_addr: ChannelAddr, ) -> Pin<Box<dyn Future<Output = Result<Self::Handle, HostError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Spawn a new proc with the provided proc id. The proc should use the provided forwarder address for messages destined outside of the proc. The returned address accepts messages destined for the proc.

An agent actor is also spawned, and the corresponding actor ref is returned.

Implementors§

Source§

impl<A> ProcManager for ProcessProcManager<A>
where A: Actor + Referable,

Source§

impl<A, S, F> ProcManager for LocalProcManager<S>
where A: Actor + Referable + Binds<A>, F: Future<Output = Result<ActorHandle<A>>> + Send, S: Fn(Proc) -> F + Sync,

Local, in-process ProcManager.

Type bounds:

  • A: Actor + Referable + Binds<A>
    • Actor: the agent actually runs inside the proc.
    • Referable: callers hold ActorRef<A> to the agent; this bound is required for typed remote refs.
    • Binds<A>: lets the runtime wire the agent’s message ports.
  • F: Future<Output = anyhow::Result<ActorHandle<A>>> + Send: the spawn closure returns a Send future (we tokio::spawn it).
  • S: Fn(Proc) -> F + Sync: the factory can be called from concurrent contexts.

Result handle is LocalHandle<A> (whose Agent = A via ProcHandle).