pub struct PipelineState<St, Req, Res, Err> { /* private fields */ }Expand description
Execution container for a service whose state is supplied per operation.
Unlike crate::Pipeline, this type does not own a state value. Callers
provide a state reference when checking readiness, calling, or shutting
down the service.
All bindings share one readiness cache and checker, including bindings with different state values. Readiness may inspect state, but must describe the shared pipeline-wide gate. Independent gates require separate pipelines.
Shutdown is advisory, as for crate::Pipeline: readiness checks return
Ok(()) once shutdown has started, and calls are still forwarded to the
service. Callers that must stop admitting work check
PipelineState::is_shutdown.
Implementations§
Source§impl<St, Req, Res, Err> PipelineState<St, Req, Res, Err>where
St: 'static,
Req: 'static,
Res: 'static,
Err: 'static,
impl<St, Req, Res, Err> PipelineState<St, Req, Res, Err>where
St: 'static,
Req: 'static,
Res: 'static,
Err: 'static,
Sourcepub fn new<S>(service: impl IntoService<S, St, Req>) -> Selfwhere
S: Service<St, Req, Res = Res, Error = Err> + 'static,
St: 'static,
pub fn new<S>(service: impl IntoService<S, St, Req>) -> Selfwhere
S: Service<St, Req, Res = Res, Error = Err> + 'static,
St: 'static,
Creates a state-independent pipeline containing service.
Sourcepub fn ready<'a>(&'a self, st: &'a St) -> impl Future<Output = Result<(), Err>>
pub fn ready<'a>(&'a self, st: &'a St) -> impl Future<Output = Result<(), Err>>
Returns when the pipeline is ready to process requests.
Successful readiness is shared and reused until a subscribed
crate::ReadyNotifier invalidates it. Calls do not consume it.
Reusing valid readiness does not allocate a readiness future.
The first caller that finds readiness invalid runs the shared check in its own future, and other waiters wait for it. Like a held lock, a pending future must be polled or dropped: keeping it alive without polling stalls every other readiness waiter on this pipeline. Returns successfully if pipeline shutdown has started.
Sourcepub fn is_ready(&self) -> bool
pub fn is_ready(&self) -> bool
Returns true while the pipeline’s shared readiness is valid.
Does not run or register a readiness check. false means readiness is
unknown or was invalidated, not that the service is not ready.
Sourcepub fn call<'a>(
&'a self,
req: Req,
st: &'a St,
) -> impl Future<Output = Result<Res, Err>>
pub fn call<'a>( &'a self, req: Req, st: &'a St, ) -> impl Future<Output = Result<Res, Err>>
Waits for readiness, then calls the service with st.
Reuses valid shared readiness without consuming it. Calls are forwarded
even after shutdown has started; see PipelineState.
Sourcepub fn shutdown<'a>(&'a self, st: &'a St) -> impl Future<Output = ()>
pub fn shutdown<'a>(&'a self, st: &'a St) -> impl Future<Output = ()>
Shuts down the enclosed service.
Marks the pipeline as shutting down, then waits for the service’s
shutdown. Later calls are not rejected; see PipelineState.
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Checks whether pipeline shutdown has been initiated.
The pipeline does not reject calls after shutdown; callers use this to stop admitting new work.
Sourcepub fn poll_ready(&self, cx: &mut Context<'_>, st: &St) -> Poll<Result<(), Err>>where
St: Clone,
pub fn poll_ready(&self, cx: &mut Context<'_>, st: &St) -> Poll<Result<(), Err>>where
St: Clone,
Returns Ready when the pipeline is ready to process requests.
Registers the task for readiness changes and reuses valid shared
readiness. A pending check is retained by the pipeline, even if this
task stops polling; other callers can continue driving it.
The retained check and its wake sources run on this pipeline’s thread.
Its checker wakers must also be finally dropped on that thread, even
after the pipeline is dropped; foreign wakes or final drops panic.
Returns Ready(Ok(())) if pipeline shutdown has started, like
crate::Pipeline::poll_ready.
Sourcepub fn bind(&self) -> PipelineStateBinding<St, Req, Res, Err>
pub fn bind(&self) -> PipelineStateBinding<St, Req, Res, Err>
Creates a binding that accepts state per call.
The binding can be used to call the service.
Sourcepub fn bind_state(&self, st: St) -> PipelineBinding<Req, Res, Err>where
St: Clone,
pub fn bind_state(&self, st: St) -> PipelineBinding<Req, Res, Err>where
St: Clone,
Creates a standard pipeline binding by attaching an owned state value.
The binding can be used to call the service.
Sourcepub fn on_notify(&self, callback: &ReadyCallback)
pub fn on_notify(&self, callback: &ReadyCallback)
Registers a callback for notifications reaching this pipeline’s scope.
Registration is shared by all bindings, regardless of their state, and
persists until the scope is dropped. Repeated registration of the same
handle is idempotent. The callback receives 0 for this root scope.
See ReadyCallback for notification semantics.
Sourcepub fn bind_to(&self, ctx: &BindCtx<'_>)
pub fn bind_to(&self, ctx: &BindCtx<'_>)
Registers this pipeline as a readiness dependency of the enclosing service.
Call from Service::bind so changes to this pipeline’s readiness also
invalidate the enclosing scope. Repeated registration is idempotent and
does not rebind the inner service or create another runtime handle.
Sourcepub fn readiness_link(&self) -> ReadyLink
pub fn readiness_link(&self) -> ReadyLink
Returns this pipeline’s readiness endpoint, shared by all state bindings.
Register with BindCtx::subscribe_pipeline. The link propagates
invalidation without checking readiness or retaining the pipeline.