Skip to main content

Module pipeline

Module pipeline 

Source
Expand description

Execution containers and shared handles for service pipelines.

A pipeline owns a service, initializes its binding dependencies, and coordinates readiness, calls, and shutdown.

Calls wait for readiness before dispatch. Successful readiness is shared by all handles until a subscribed crate::ReadyNotifier invalidates it; neither a call nor a different state value consumes that success. Independent readiness gates require separate pipelines or crate::ReadyBinding wrappers.

Pipelines and their handles are local to a thread. Services whose readiness changes must subscribe in Service::bind and notify on those changes; waking a task alone does not invalidate cached readiness.

§Example

use ntex_service::pipeline::{Pipeline, PipelineState};

let pipeline = Pipeline::new(
    10u32,
    async |state: &u32, req: u32| Ok::<_, ()>(*state + req),
);
let handle = pipeline.bind();
assert_eq!(handle.call(2).await?, 12);

let stateful = PipelineState::new(
    async |state: &u32, req: u32| Ok::<_, ()>(*state + req),
);
assert_eq!(stateful.call(2, &20).await?, 22);
assert_eq!(stateful.call(2, &30).await?, 32);

§Framework guide

Structs§

Pipeline
Execution container for a service and its state.
PipelineBinding
An independently registered handle to a Pipeline.
PipelineCall
An owned future for a pipeline service call.
PipelineFactory
Factory for a service pipeline.
PipelineState
Execution container for a service whose state is supplied per operation.
PipelineStateBinding
An independently registered handle to a PipelineState.