pub trait Spawnable: Send + 'static {
// Required methods
fn name(&self) -> &str;
fn registrations(&self) -> Vec<(SocketKind, TransportConfig)>;
fn run(
self: Box<Self>,
shutdown: Arc<Notify>,
on_ready: Option<Sender<()>>,
) -> Result<(), RpcError>;
}Expand description
Trait for services that can be spawned by ServiceSpawner.
Implemented by both REQ/REP handlers and XSUB/XPUB proxies. This provides a unified spawning API regardless of service type.
Required Methods§
Sourcefn registrations(&self) -> Vec<(SocketKind, TransportConfig)>
fn registrations(&self) -> Vec<(SocketKind, TransportConfig)>
Endpoints to register with EndpointRegistry.
Each tuple is (SocketKind, TransportConfig).
- Handlers typically register one REP endpoint
- Proxies register PUB and SUB endpoints (note socket type inversion)
Sourcefn run(
self: Box<Self>,
shutdown: Arc<Notify>,
on_ready: Option<Sender<()>>,
) -> Result<(), RpcError>
fn run( self: Box<Self>, shutdown: Arc<Notify>, on_ready: Option<Sender<()>>, ) -> Result<(), RpcError>
Run the service on current thread (blocking).
Called by spawner after thread/process setup. Should block until shutdown is signaled.
§Arguments
shutdown- Notification to signal service shutdownon_ready- Optional oneshot sender to signal when socket is bound and ready
Implementations on Foreign Types§
Source§impl Spawnable for DualSpawnable
impl Spawnable for DualSpawnable
Source§impl<S> Spawnable for UnifiedServiceConfig<S>
impl<S> Spawnable for UnifiedServiceConfig<S>
Implementors§
impl<S> Spawnable for QuicServiceLoop<S>
impl<S> Spawnable for S
Every RequestService + Send + Sync is automatically Spawnable.
This blanket implementation eliminates the need for wrapper types.
Services that implement RequestService include their infrastructure
(context, transport, verifying_key) and can be spawned directly.
Services not satisfying Send + Sync (e.g., those using Rc or !Send fields)
must implement Spawnable directly (as InferenceServiceConfig does).