Skip to main content

Pipeline

Struct Pipeline 

Source
pub struct Pipeline<Req, Res, Err> { /* private fields */ }
Expand description

Execution container for a service and its state.

A pipeline coordinates readiness, calls, and shutdown for the enclosed service chain.

Implementations§

Source§

impl<Req, Res, Err> Pipeline<Req, Res, Err>
where Req: 'static, Res: 'static, Err: 'static,

Source

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

Creates a pipeline containing service and state.

Source

pub async fn ready(&self) -> Result<(), Err>

Returns when the pipeline is ready to process requests.

A successful check is consumed by the next call, which then skips its own readiness check.

Source

pub async fn call(&self, req: Req) -> Result<Res, Err>

Waits for readiness, then calls the service.

The readiness check is skipped if the last pipeline readiness check succeeded and no call has started since.

Source

pub fn call_static(&self, req: Req) -> PipelineCall<Req, Res, Err> ⓘ

Returns an owned future that waits for readiness and calls the service.

Unlike Pipeline::call, the returned future does not borrow the pipeline and can be moved between local tasks. The readiness check is skipped if the last pipeline readiness check succeeded and no call has started since; this is decided when the future is first polled.

Source

pub fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Err>>

Returns Ready when the pipeline is ready to process requests.

A successful check is consumed by the next call, which then skips its own readiness check.

Source

pub fn poll_shutdown(&self, cx: &mut Context<'_>) -> Poll<()>

Returns Ready when the service has been properly shut down.

Source

pub fn is_shutdown(&self) -> bool

Checks whether pipeline shutdown has been initiated.

Source

pub async fn shutdown(&self)

Shuts down the enclosed service.

Source

pub fn bind(&self) -> PipelineBinding<Req, Res, Err>

Creates a new binding to this pipeline.

The binding can be used to check readiness and call the service.

Trait Implementations§

Source§

impl<Req, Res, Err> Debug for Pipeline<Req, Res, Err>

Source§

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

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

impl<Req, Res, Err> Drop for Pipeline<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
Source§

impl<Req, Res, Err> ServiceCaller<Req, Res, Err> for Pipeline<Req, Res, Err>
where Req: 'static, Res: 'static, Err: 'static,

Source§

async fn call_service(&self, req: Req) -> Result<Res, Err>

Waits for readiness, then calls the service.

Auto Trait Implementations§

§

impl<Req, Res, Err> !RefUnwindSafe for Pipeline<Req, Res, Err>

§

impl<Req, Res, Err> !Send for Pipeline<Req, Res, Err>

§

impl<Req, Res, Err> !Sync for Pipeline<Req, Res, Err>

§

impl<Req, Res, Err> !UnwindSafe for Pipeline<Req, Res, Err>

§

impl<Req, Res, Err> Freeze for Pipeline<Req, Res, Err>

§

impl<Req, Res, Err> Unpin for Pipeline<Req, Res, Err>

§

impl<Req, Res, Err> UnsafeUnpin for Pipeline<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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.