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 are executed.
- Telemetry policy.
- Retry policy. 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 are executed.
- Authorization policy. Authorization can depend on the HTTP headers and/or the request body so it must be executed right before sending the request to the transport. Also, the authorization can depend on the current time so it must be executed at every retry.
- Transport policy. Transport policy is always the last policy and is the policy that
actually constructs the
Response
to 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).
The C
generic contains the pipeline-specific context. Different crates can pass
different contexts using this generic. This way each crate can have its own specific pipeline
context. For example, in CosmosDB
, the generic carries the operation-specific information used by
the authorization policy.
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_retry_policies: Vec<Arc<dyn Policy>>,
) -> Self
pub fn new( crate_name: Option<&'static str>, crate_version: Option<&'static str>, options: ClientOptions, per_call_policies: Vec<Arc<dyn Policy>>, per_retry_policies: Vec<Arc<dyn Policy>>, ) -> 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.
pub fn replace_policy( &mut self, policy: Arc<dyn Policy>, position: usize, ) -> Arc<dyn Policy>
pub fn policies(&self) -> &[Arc<dyn Policy>]
pub async fn send( &self, ctx: &Context, request: &mut Request, ) -> Result<Response>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pipeline
impl !RefUnwindSafe for Pipeline
impl Send for Pipeline
impl Sync for Pipeline
impl Unpin for Pipeline
impl !UnwindSafe for Pipeline
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)