pub struct RequestTracker { /* private fields */ }Expand description
Monotonically-increasing token minter + in-flight tracker.
Implementations§
Source§impl RequestTracker
impl RequestTracker
Sourcepub fn mint_token(&mut self) -> CommandId
pub fn mint_token(&mut self) -> CommandId
Mint a fresh correlation token (used by CorrelateTag +
wire::Send to identify the round trip).
Sourcepub fn register_in_flight(
&mut self,
wire_req_id: u64,
started_at_ns: u64,
target_site: NodeSiteId,
chain: Option<ChainContext>,
ttl_ns: NonZeroU64,
parked_op: Option<CommandId>,
)
pub fn register_in_flight( &mut self, wire_req_id: u64, started_at_ns: u64, target_site: NodeSiteId, chain: Option<ChainContext>, ttl_ns: NonZeroU64, parked_op: Option<CommandId>, )
Record an outbound wire round-trip’s dispatch-time
bookkeeping. wire_req_id is the token returned by
Self::mint_token; reused on the response side to match.
ttl_ns is the maximum age the entry will survive before
the tracker considers it stale (typed as
NonZeroU64 so callers cannot accidentally register an
entry that never expires, which was the only failure mode
the RequestTracker.in_flight map had as an unbounded
resource). parked_op is the CommandId of the originator’s
local op parked waiting for the chain response; None for
entries registered outside an async-suspension context.
Sourcepub fn observe_response(
&mut self,
wire_req_id: u64,
now_ns: u64,
) -> Option<RoundTripSample>
pub fn observe_response( &mut self, wire_req_id: u64, now_ns: u64, ) -> Option<RoundTripSample>
Pop the in-flight entry for a landing response and surface
the elapsed-time sample the RTT tracker should observe.
Returns None when no matching in-flight entry exists (the
response is unsolicited, duplicate, or fired before the
tracker was populated).
Sourcepub fn peek(&self, wire_req_id: u64) -> Option<&InFlightSend>
pub fn peek(&self, wire_req_id: u64) -> Option<&InFlightSend>
Read-only peek at an in-flight entry without consuming it.
Sourcepub fn in_flight_count(&self) -> usize
pub fn in_flight_count(&self) -> usize
Count of currently in-flight round trips.
Sourcepub fn drain_stale(&mut self, now_ns: u64) -> Vec<(u64, InFlightSend)>
pub fn drain_stale(&mut self, now_ns: u64) -> Vec<(u64, InFlightSend)>
Drain in-flight entries whose per-entry expires_at_ns has
passed (entries with expires_at_ns == 0 never expire on
age). Returns the dropped entries so the engine can emit
EngineStep::WireTimeout and fail any parked CommandId.
Trait Implementations§
Source§impl Default for RequestTracker
impl Default for RequestTracker
Source§fn default() -> RequestTracker
fn default() -> RequestTracker
Auto Trait Implementations§
impl Freeze for RequestTracker
impl RefUnwindSafe for RequestTracker
impl Send for RequestTracker
impl Sync for RequestTracker
impl Unpin for RequestTracker
impl UnsafeUnpin for RequestTracker
impl UnwindSafe for RequestTracker
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
impl<T> ErasedComponent for 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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request