pub struct OperationContext { /* private fields */ }Expand description
Composed resources passed from operator to services and layers.
Operator keeps a base OperationContext and replays its
layers to produce the composed context passed to every service operation.
The context carries runtime resources supplied by the operator stack, not
caller intent for a specific operation. Operation-specific inputs live in
Op* argument structs such as OpRead and OpWrite.
Service implementations should read HTTP transport, executor, and similar
resources from the OperationContext they receive at the operation boundary.
They should not cache those resources in the service created by
Builder::build, because later layers or Operator::with_context can
replace them for a derived operator.
Layers that replace the HTTP transport or executor must keep forwarding requests or tasks to the previous value. Otherwise, composed features such as retry, timeout, tracing, and metrics can be bypassed.
Implementations§
Source§impl OperationContext
impl OperationContext
Sourcepub fn from_parts(http_transport: HttpTransporter, executor: Executor) -> Self
pub fn from_parts(http_transport: HttpTransporter, executor: Executor) -> Self
Create a new operation context from composed runtime resources.
Sourcepub fn with_http_transport(&self, http_transport: HttpTransporter) -> Self
pub fn with_http_transport(&self, http_transport: HttpTransporter) -> Self
Return a copy of this context with a different HTTP transport.
Sourcepub fn with_executor(&self, executor: Executor) -> Self
pub fn with_executor(&self, executor: Executor) -> Self
Return a copy of this context with a different executor.
Sourcepub fn into_parts(self) -> (HttpTransporter, Executor)
pub fn into_parts(self) -> (HttpTransporter, Executor)
Split into composed resources.
Sourcepub fn http_transport(&self) -> &HttpTransporter
pub fn http_transport(&self) -> &HttpTransporter
Get the composed HTTP transport.
Trait Implementations§
Source§impl Clone for OperationContext
impl Clone for OperationContext
Source§fn clone(&self) -> OperationContext
fn clone(&self) -> OperationContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more