pub struct RpcServerFold { /* private fields */ }Expand description
Server-side fold. Sees REQUEST events on the configured channel, dispatches to the user-supplied handler, emits RESPONSE events via the supplied emitter. CANCEL events flip the matching in-flight token.
State () — the user’s state lives on whatever the RpcHandler
captures (typically Arc<Mutex<S>>). The fold’s own state (the
in-flight map) lives on &mut self and is shared with spawned
handler tasks via Arc<Mutex<...>> so the task can self-clean
on completion.
Implementations§
Source§impl RpcServerFold
impl RpcServerFold
Sourcepub fn new(handler: Arc<dyn RpcHandler>, emit: RpcResponseEmitter) -> Self
pub fn new(handler: Arc<dyn RpcHandler>, emit: RpcResponseEmitter) -> Self
Construct a server fold around handler. emit is the
callback that publishes RESPONSE events to the caller’s
reply channel — Mesh::serve_rpc wires this to the
publisher for <service>.replies.<caller_origin>.
Constructed without a metrics handle; production callers
chain .with_metrics(...) to opt into per-service
counters.
Sourcepub fn with_metrics(self, metrics: Arc<ServiceMetricsAtomic>) -> Self
pub fn with_metrics(self, metrics: Arc<ServiceMetricsAtomic>) -> Self
Attach a per-service metrics handle. Hooks the spawned
handler task to bump handler_invocations_total, balance
handler_in_flight, count panics, and record handler
duration into the histogram.
Trait Implementations§
Source§impl RedexFold<()> for RpcServerFold
impl RedexFold<()> for RpcServerFold
Source§fn apply(&mut self, ev: &RedexEvent, _state: &mut ()) -> Result<(), RedexError>
fn apply(&mut self, ev: &RedexEvent, _state: &mut ()) -> Result<(), RedexError>
state. Return an error to stop the fold.