pub struct SignalArbiter { /* private fields */ }signals only.Expand description
Shared arbiter used to register and dispatch named signals.
Implementations§
Source§impl SignalArbiter
impl SignalArbiter
Sourcepub fn set_global_broadcast_capacity(capacity: usize)
pub fn set_global_broadcast_capacity(capacity: usize)
Sets the global broadcast capacity used for topic channels.
This affects all newly created topics across all arbiters.
Sourcepub fn global_broadcast_capacity() -> usize
pub fn global_broadcast_capacity() -> usize
Returns the current global broadcast capacity.
Sourcepub fn on<F, Fut>(&self, id: impl Into<String>, handler: F)
pub fn on<F, Fut>(&self, id: impl Into<String>, handler: F)
Registers a handler for the given signal id.
Handlers are invoked in registration order whenever a matching signal is emitted.
Sourcepub fn subscribe(&self, id: impl AsRef<str>) -> Receiver<Signal>
pub fn subscribe(&self, id: impl AsRef<str>) -> Receiver<Signal>
Subscribes to a broadcast channel for the given signal id.
This is useful for long-lived listeners such as metrics collectors, background workers, plugins, or middleware driven tasks.
Sourcepub fn subscribe_prefix(&self, prefix: impl AsRef<str>) -> Receiver<Signal>
pub fn subscribe_prefix(&self, prefix: impl AsRef<str>) -> Receiver<Signal>
Subscribes to all signals whose id starts with the given prefix.
For example, subscribe_prefix("request.") will receive
request.started, request.completed, etc.
Sourcepub fn subscribe_all(&self) -> Receiver<Signal>
pub fn subscribe_all(&self) -> Receiver<Signal>
Subscribes to all signals regardless of their id.
This is a special variant that receives every emitted signal. Internally uses a wildcard prefix matching (empty prefix = all signals).
Sourcepub fn subscribe_filtered<F>(
&self,
id: impl AsRef<str>,
filter: F,
) -> SignalStream
pub fn subscribe_filtered<F>( &self, id: impl AsRef<str>, filter: F, ) -> SignalStream
Subscribes using a filter function on top of an id-based subscription.
This spawns a background task that forwards only matching signals into
an unbounded channel, which is returned as a SignalStream.
Sourcepub async fn once(&self, id: impl AsRef<str>) -> Option<Signal>
pub async fn once(&self, id: impl AsRef<str>) -> Option<Signal>
Waits for the next occurrence of a signal id (oneshot-style).
This uses the broadcast channel under the hood but resolves on the first successfully received signal.
Sourcepub fn register_rpc<Req, Res, F, Fut>(&self, id: impl Into<String>, f: F)
pub fn register_rpc<Req, Res, F, Fut>(&self, id: impl Into<String>, f: F)
Registers a typed RPC handler under the given id.
This allows request/response style interactions over the same arbiter, using type-erased storage internally for flexibility.
Sourcepub async fn call_rpc_arc<Req, Res>(
&self,
id: impl AsRef<str>,
req: Req,
) -> Option<Arc<Res>>
pub async fn call_rpc_arc<Req, Res>( &self, id: impl AsRef<str>, req: Req, ) -> Option<Arc<Res>>
Calls a typed RPC handler and returns a shared pointer to the response.
Sourcepub async fn call_rpc_result<Req, Res>(
&self,
id: impl AsRef<str>,
req: Req,
) -> RpcResult<Res>
pub async fn call_rpc_result<Req, Res>( &self, id: impl AsRef<str>, req: Req, ) -> RpcResult<Res>
Calls a typed RPC handler and returns an owned response with an error type.
Sourcepub async fn call_rpc<Req, Res>(
&self,
id: impl AsRef<str>,
req: Req,
) -> Option<Res>
pub async fn call_rpc<Req, Res>( &self, id: impl AsRef<str>, req: Req, ) -> Option<Res>
Calls a typed RPC handler and returns an owned response.
Sourcepub async fn call_rpc_timeout<Req, Res>(
&self,
id: impl AsRef<str>,
req: Req,
dur: Duration,
) -> Result<Res, RpcTimeoutError>
pub async fn call_rpc_timeout<Req, Res>( &self, id: impl AsRef<str>, req: Req, dur: Duration, ) -> Result<Res, RpcTimeoutError>
Calls a typed RPC handler with a timeout.
Sourcepub async fn emit(&self, signal: Signal)
pub async fn emit(&self, signal: Signal)
Emits a signal and awaits all registered handlers.
Handlers run concurrently and this method resolves once all handlers have completed.
Sourcepub async fn emit_app(signal: Signal)
pub async fn emit_app(signal: Signal)
Emits a signal using the global application-level arbiter.
Sourcepub fn register_exporter<F>(&self, exporter: F)
pub fn register_exporter<F>(&self, exporter: F)
Registers a global exporter that is invoked for every emitted signal.
Exporters are merged when routers are merged, similar to handlers.
Sourcepub fn signal_ids(&self) -> Vec<String>
pub fn signal_ids(&self) -> Vec<String>
Returns a list of known signal ids (exact topics) currently registered.
Sourcepub fn signal_prefixes(&self) -> Vec<String>
pub fn signal_prefixes(&self) -> Vec<String>
Returns a list of known signal prefixes (topics ending with ‘*’).
Trait Implementations§
Source§impl Clone for SignalArbiter
impl Clone for SignalArbiter
Source§fn clone(&self) -> SignalArbiter
fn clone(&self) -> SignalArbiter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more