pub struct RpcServerStreamingFold { /* private fields */ }Expand description
Server-side fold for streaming RPC. Parallel to RpcServerFold
but multi-fire emit: each handler invocation may produce many
RESPONSE events for the same call_id, marked
non-terminal/terminal via the nrpc-streaming header.
State () — like the unary fold, the handler owns user state
via captured Arc<Mutex<S>>. The fold’s own state (in-flight
cancellation tokens) lives on &mut self.
Implementations§
Source§impl RpcServerStreamingFold
impl RpcServerStreamingFold
Sourcepub fn new(
handler: Arc<dyn RpcStreamingHandler>,
emit: RpcAsyncResponseEmitter,
) -> Self
pub fn new( handler: Arc<dyn RpcStreamingHandler>, emit: RpcAsyncResponseEmitter, ) -> Self
Construct a streaming server fold. emit publishes
individual chunks (and the terminal frame) on the caller’s
reply channel.
Uses the async emitter variant so the pump task can serialize per-call publishes — without that ordering guarantee, two chunks emitted in succession can race into the publish path and arrive at the caller out of order (or be eclipsed by the terminal frame and lost entirely).
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 /
handler_in_flight / handler_panics_total /
handler_duration_*, and the pump task to bump
streaming_chunks_emitted_total per emitted chunk.
Trait Implementations§
Source§impl RedexFold<()> for RpcServerStreamingFold
impl RedexFold<()> for RpcServerStreamingFold
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.