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.
Pipelineowns one state value for all operations.PipelineStateaccepts a state reference for each operation instead.PipelineBindingandPipelineStateBindingprovide independently registered handles to the same service and readiness machinery.PipelineState::bind_stateattaches an owned state value to a handle.PipelineCallis an owned call future that keeps its pipeline alive without borrowing the originating handle.PipelineFactorycreates a service and wraps it with its state.
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.
- Pipeline
Binding - An independently registered handle to a
Pipeline. - Pipeline
Call - An owned future for a pipeline service call.
- Pipeline
Factory - Factory for a service pipeline.
- Pipeline
State - Execution container for a service whose state is supplied per operation.
- Pipeline
State Binding - An independently registered handle to a
PipelineState.