Skip to main content

PipelineState

Struct PipelineState 

Source
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,

Source

pub fn new<S>(service: impl IntoService<S, St, Req>) -> Self
where S: Service<St, Req, Res = Res, Error = Err> + 'static, St: 'static,

Creates a state-independent pipeline containing service.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

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.

Trait Implementations§

Source§

impl<St, Req, Res, Err> Debug for PipelineState<St, Req, Res, Err>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<St, Req, Res, Err> Drop for PipelineState<St, Req, Res, Err>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<St, Req, Res, Err> !RefUnwindSafe for PipelineState<St, Req, Res, Err>

§

impl<St, Req, Res, Err> !Send for PipelineState<St, Req, Res, Err>

§

impl<St, Req, Res, Err> !Sync for PipelineState<St, Req, Res, Err>

§

impl<St, Req, Res, Err> !UnwindSafe for PipelineState<St, Req, Res, Err>

§

impl<St, Req, Res, Err> Freeze for PipelineState<St, Req, Res, Err>

§

impl<St, Req, Res, Err> Unpin for PipelineState<St, Req, Res, Err>

§

impl<St, Req, Res, Err> UnsafeUnpin for PipelineState<St, Req, Res, Err>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.