Trait tower::load::completion::TrackCompletion[][src]

pub trait TrackCompletion<H, V>: Clone {
    type Output;
    fn track_completion(&self, handle: H, value: V) -> Self::Output;
}
This is supported on crate feature load only.
Expand description

Attaches H-typed completion tracker to V typed values.

Handles (of type H) are intended to be RAII guards that primarily implement Drop and update load metric state as they are dropped. This trait allows implementors to “forward” the handle to later parts of the request-handling pipeline, so that the handle is only dropped when the request has truly completed.

This utility allows load metrics to have a protocol-agnostic means to track streams past their initial response future. For example, if V represents an HTTP response type, an implementation could add H-typed handles to each response’s extensions to detect when all the response’s extensions have been dropped.

A base impl<H, V> TrackCompletion<H, V> for CompleteOnResponse is provided to drop the handle once the response future is resolved. This is appropriate when a response is discrete and cannot comprise multiple messages.

In many cases, the Output type is simply V. However, TrackCompletion may alter the type in order to instrument it appropriately. For example, an HTTP TrackCompletion may modify the body type: so a TrackCompletion that takes values of type http::Response<A> may output values of type http::Response<B>.

Associated Types

The instrumented value type.

Required methods

Attaches a H-typed handle to a V-typed value.

Implementors