pub struct Pipeline(/* private fields */);Expand description
Execution pipeline.
A pipeline follows a precise flow:
- Client library-specified per-call policies are executed. Per-call policies can fail and bail out of the pipeline immediately.
- User-specified per-call policies in
ClientOptions::per_call_policiesare executed. - The retry policy is executed. It allows to re-execute the following policies.
- Client library-specified per-retry policies. Per-retry polices are always executed at least once but are re-executed in case of retries.
- User-specified per-retry policies in
ClientOptions::per_try_policiesare executed. - The transport policy is executed. Transport policy is always the last policy and is the policy that
actually constructs the
AsyncRawResponseto be passed up the pipeline.
A pipeline is immutable. In other words a policy can either succeed and call the following
policy of fail and return to the calling policy. Arbitrary policy “skip” must be avoided (but
cannot be enforced by code). All policies except Transport policy can assume there is another following policy (so
self.pipeline[0] is always valid).
Implementations§
Source§impl Pipeline
impl Pipeline
Sourcepub fn new(
crate_name: Option<&'static str>,
crate_version: Option<&'static str>,
options: ClientOptions,
per_call_policies: Vec<Arc<dyn Policy>>,
per_try_policies: Vec<Arc<dyn Policy>>,
pipeline_options: Option<PipelineOptions>,
) -> Self
pub fn new( crate_name: Option<&'static str>, crate_version: Option<&'static str>, options: ClientOptions, per_call_policies: Vec<Arc<dyn Policy>>, per_try_policies: Vec<Arc<dyn Policy>>, pipeline_options: Option<PipelineOptions>, ) -> Self
Creates a new pipeline given the client library crate name and version, alone with user-specified and client library-specified policies.
Crates can simply pass option_env!("CARGO_PKG_NAME") and option_env!("CARGO_PKG_VERSION") for the
crate_name and crate_version arguments respectively.
§Arguments
crate_name- The name of the crate implementing the client library.crate_version- The version of the crate implementing the client library.options- The client options.per_call_policies- Policies to be executed per call, before the policies inClientOptions::per_call_policies.per_try_policies- Policies to be executed per try, before the policies inClientOptions::per_try_policies.pipeline_options- Additional options for the pipeline. IfNone, default options will be used.
Sourcepub async fn send(
&self,
ctx: &Context<'_>,
request: &mut Request,
options: Option<PipelineSendOptions>,
) -> Result<RawResponse>
pub async fn send( &self, ctx: &Context<'_>, request: &mut Request, options: Option<PipelineSendOptions>, ) -> Result<RawResponse>
Sends a Request through each configured Policy to get a RawResponse that is processed by each policy in reverse.
§Arguments
ctx- The context for theRequest.request- TheRequestto send.options- Options for sending theRequest, including check success options. If none,check_successwill not be called.
§Returns
A http::RawResponse if the request was successful, or an Error if it failed.
If the response status code indicates an HTTP error, the function will attempt to parse the error response
body into an ErrorResponse and include it in the Error.
Sourcepub async fn stream(
&self,
ctx: &Context<'_>,
request: &mut Request,
options: Option<PipelineStreamOptions>,
) -> Result<AsyncRawResponse>
pub async fn stream( &self, ctx: &Context<'_>, request: &mut Request, options: Option<PipelineStreamOptions>, ) -> Result<AsyncRawResponse>
Sends a Request through each configured Policy to get a AsyncRawResponse that is processed by each policy in reverse.
§Arguments
ctx- The context for theRequest.request- TheRequestto send.options- Options for sending theRequest, including check success options. If none,check_successwill not be called.
§Returns
A http::RawResponse if the request was successful, or an Error if it failed.
If the response status code indicates an HTTP error, the function will attempt to parse the error response
body into an ErrorResponse and include it in the Error.