pub struct Tracker<Con, Context = (), State = ()>{ /* private fields */ }Expand description
Tracks in-flight consumer deliveries keyed by resolver key.
Context carries resolver-specific metadata back to the caller when
validation completes.
State holds per-key resolver state that should be dropped when the key is
pruned, or explicitly taken when the resolver completes the fetch.
Implementations§
Source§impl<Con, Context, State> Tracker<Con, Context, State>
impl<Con, Context, State> Tracker<Con, Context, State>
Sourcepub fn contains(&self, key: &Con::Key) -> bool
pub fn contains(&self, key: &Con::Key) -> bool
Returns true when the key has an active tracked fetch.
Sourcepub fn remove(&mut self, key: &Con::Key) -> bool
pub fn remove(&mut self, key: &Con::Key) -> bool
Remove a key and abort any in-progress delivery for it.
Returns true if the key was present. Any completion produced by an
aborted delivery is discarded by next_completion.
Sourcepub fn retain<F: FnMut(&Con::Key) -> bool>(&mut self, predicate: F) -> usize
pub fn retain<F: FnMut(&Con::Key) -> bool>(&mut self, predicate: F) -> usize
Retain only entries for which the predicate returns true.
Dropped entries abort in-progress deliveries. Returns the number of removed entries.
Sourcepub fn drain(&mut self) -> usize
pub fn drain(&mut self) -> usize
Remove all entries and abort all in-progress deliveries.
Returns the number of entries removed.
Sourcepub fn deliver(
&mut self,
delivery: Delivery<Con::Key, Con::Subscriber>,
context: Context,
value: Con::Value,
)
pub fn deliver( &mut self, delivery: Delivery<Con::Key, Con::Subscriber>, context: Context, value: Con::Value, )
Deliver a newly received response to the consumer.
The response is cached so that, after the consumer accepts it, later
retained subscribers can be redelivered the same bytes with
redeliver. Panics if the key is not tracked.
Sourcepub fn redeliver(&mut self, delivery: Delivery<Con::Key, Con::Subscriber>)
pub fn redeliver(&mut self, delivery: Delivery<Con::Key, Con::Subscriber>)
Deliver the cached response to another set of subscribers.
This is intended for subscribers added while the first validation was still pending. Panics if the key is not tracked, no response is cached, or the cached response has not yet been accepted.
Sourcepub fn response_accepted(&self, key: &Con::Key) -> bool
pub fn response_accepted(&self, key: &Con::Key) -> bool
Returns true if the cached response for this key has been accepted.
Sourcepub fn accept_response(&mut self, key: &Con::Key)
pub fn accept_response(&mut self, key: &Con::Key)
Mark the cached response accepted by the consumer.
Panics if the key is not tracked or no response is cached.
Sourcepub fn discard_response(&mut self, key: &Con::Key)
pub fn discard_response(&mut self, key: &Con::Key)
Drop the cached response without removing the tracked key.
Use this after a consumer rejects a response and the resolver wants to retry the same key with different bytes or metadata.
Sourcepub async fn next_completion(
&mut self,
) -> Result<Completion<Con::Key, Con::Subscriber, Context>, Aborted>
pub async fn next_completion( &mut self, ) -> Result<Completion<Con::Key, Con::Subscriber, Context>, Aborted>
Wait for the next consumer validation result.
Returns Aborted when the delivery was canceled before completion.
Successful completions clear the active delivery slot for that key so it
can be retried or redelivered. Completions for an older same-key delivery
are treated as aborted.
Auto Trait Implementations§
impl<Con, Context = (), State = ()> !Freeze for Tracker<Con, Context, State>
impl<Con, Context = (), State = ()> !RefUnwindSafe for Tracker<Con, Context, State>
impl<Con, Context, State> Send for Tracker<Con, Context, State>
impl<Con, Context = (), State = ()> !Sync for Tracker<Con, Context, State>
impl<Con, Context, State> Unpin for Tracker<Con, Context, State>
impl<Con, Context, State> UnsafeUnpin for Tracker<Con, Context, State>
impl<Con, Context = (), State = ()> !UnwindSafe for Tracker<Con, Context, State>
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more