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.
Source§impl RpcServerFold
impl RpcServerFold
Sourcepub fn apply_inbound(&mut self, ev: &RpcInboundEvent) -> Result<(), RedexError>
pub fn apply_inbound(&mut self, ev: &RpcInboundEvent) -> Result<(), RedexError>
Production-path entry point. The serve bridge calls this with
the AEAD-verified session peer’s NodeId in ev.from_node;
all per-call state is keyed by (from_node, claimed_origin, call_id) so no peer can create, cancel, or otherwise mutate
another peer’s call by copying its origin + call_id (AV-1
item 1).
Sourcepub fn apply_inbound_admitted(
&mut self,
ev: &RpcInboundEvent,
admitted: Admitted,
) -> Result<(), RedexError>
pub fn apply_inbound_admitted( &mut self, ev: &RpcInboundEvent, admitted: Admitted, ) -> Result<(), RedexError>
OA-2 protected entry point (E1.6). The protected serve bridge
calls this AFTER verify_org_admission succeeds, handing the
four-party Admitted
attribution the fold places into RpcContext::org_admission; the
fold also STRIPS every net-org-admission header from the payload
so the handler never sees the raw proof. Unary-only — the
streaming/duplex folds have no admitted entry point (E1.8).
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>
Loopback / test shim: no session peer to resolve, so this
drives apply_frame with from_node = 0 (AV-1 item 1). The
production wire path uses RpcServerFold::apply_inbound.