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 is dropped when the key is pruned.
While the key stays tracked, the resolver can read, update, or take it.
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. A verdict accepted before cancellation
closes its receiver is returned as a canceled 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 later retained subscribers can be
redelivered the same bytes with redeliver once the
consumer accepts it or drops its verdict. 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 an earlier validation was still pending. The cached response is either accepted or still unjudged because the consumer dropped the earlier verdict. Panics if the key is not tracked or no response is cached.
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 when a response is invalid or does not satisfy every delivered subscriber and the resolver wants to retry the key.
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 cancellation closes the receiver without an accepted
verdict. Otherwise, canceled deliveries return their verdict for source
accounting without affecting any current fetch for the key. Active deliveries
clear their slot so the key can be retried or redelivered. A verdict sender
dropped by the consumer completes with no outcome.
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 = ()> !Sync for Tracker<Con, Context, State>
impl<Con, Context = (), State = ()> !UnwindSafe for Tracker<Con, Context, State>
impl<Con, Context, State> Send 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>where
<Con as Consumer>::Value: Sized,
AHashMap<<Con as Consumer>::Key, Entry<Context, <Con as Consumer>::Value, State>>: UnsafeUnpin,
Pool<'static, Result<Completion<<Con as Consumer>::Key, <Con as Consumer>::Subscriber, Context>, Aborted>>: UnsafeUnpin,
Con: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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