pub struct Requester<E: Clock + GClock + Rng + Metrics, P: PublicKey> { /* private fields */ }Expand description
Send rate-limited requests to peers prioritized by performance.
Requester attempts to saturate the bandwidth (inferred by rate limit)
of the most performant peers (based on our latency observations). To encourage
exploration, set the value of initial to less than the expected latency of
performant peers and/or periodically set shuffle in request.
Implementations§
Source§impl<E: Clock + GClock + Rng + Metrics, P: PublicKey> Requester<E, P>
impl<E: Clock + GClock + Rng + Metrics, P: PublicKey> Requester<E, P>
Sourcepub fn reconcile(&mut self, participants: &[P])
pub fn reconcile(&mut self, participants: &[P])
Indicate which participants can be sent requests.
Sourcepub fn block(&mut self, participant: P)
pub fn block(&mut self, participant: P)
Skip a participant for future requests.
Participants added to this list will never be removed (even if dropped
during reconcile, in case they are re-added later).
Sourcepub fn request(&mut self, shuffle: bool) -> Option<(P, ID)>
pub fn request(&mut self, shuffle: bool) -> Option<(P, ID)>
Ask for a participant to handle a request.
If shuffle is true, the order of participants is shuffled before
a request is made. This is typically used when a request to the preferred
participant fails.
Sourcepub fn cancel(&mut self, id: ID) -> Option<Request<P>>
pub fn cancel(&mut self, id: ID) -> Option<Request<P>>
Drop an outstanding request regardless of who it was intended for.
Sourcepub fn handle(&mut self, participant: &P, id: ID) -> Option<Request<P>>
pub fn handle(&mut self, participant: &P, id: ID) -> Option<Request<P>>
Handle a request by ID, ensuring the provided participant was
associated with said ID.
If the request was outstanding, a Request is returned that can
either be resolved or timed out.
Sourcepub fn fail(&mut self, request: Request<P>)
pub fn fail(&mut self, request: Request<P>)
Fail an outstanding request and penalize the request participant with the timeout duration.
This is used when we fail to send a request to a participant.
Sourcepub fn next(&self) -> Option<(ID, SystemTime)>
pub fn next(&self) -> Option<(ID, SystemTime)>
Get the next outstanding ID and deadline.
Sourcepub fn len_blocked(&self) -> usize
pub fn len_blocked(&self) -> usize
Get the number of blocked participants.
Auto Trait Implementations§
impl<E, P> !Freeze for Requester<E, P>
impl<E, P> !RefUnwindSafe for Requester<E, P>
impl<E, P> Send for Requester<E, P>
impl<E, P> Sync for Requester<E, P>
impl<E, P> Unpin for Requester<E, P>
impl<E, P> !UnwindSafe for Requester<E, P>
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