pub struct TimedWindows<const N: usize> { /* private fields */ }Expand description
The open Timed transaction windows of a node.
N is how many may be open at once. One per concurrent administrator is generous: a Timed
transaction’s whole life is one round trip plus a timeout the client chose, and a client
with two open at once on the same session is already misbehaving.
Implementations§
Source§impl<const N: usize> TimedWindows<N>
impl<const N: usize> TimedWindows<N>
Sourcepub fn open(
&mut self,
session: Option<SessionId>,
exchange: ExchangeId,
timeout_ms: u16,
sent_at: Instant,
) -> Result<()>
pub fn open( &mut self, session: Option<SessionId>, exchange: ExchangeId, timeout_ms: u16, sent_at: Instant, ) -> Result<()>
Opens a window, as §8.7.4.3 requires after answering a Timed Request.
sent_at is when the SUCCESS status response went out, not when the Timed Request
arrived: §8.7.4, “the Timeout interval SHALL start when the Status Response action
acknowledging the Timed Request action with a success code is sent”.
A second Timed Request on the same exchange replaces the first: one transaction, one deadline.
§Errors
ErrorCode::NoSpace when every slot holds a live window —
§8.7.3.2’s BUSY case, so a caller answers Status::Busy rather than pretending the
window opened.
Sourcepub fn check(
&mut self,
session: Option<SessionId>,
exchange: ExchangeId,
timed_request: bool,
now: Instant,
) -> Result<bool, Status>
pub fn check( &mut self, session: Option<SessionId>, exchange: ExchangeId, timed_request: bool, now: Instant, ) -> Result<bool, Status>
Applies §8.7.3.2 and §8.8.2.3’s timed rules to an arriving Write or Invoke Request.
timed_request is the request’s own TimedRequest flag. Returns what
InteractionContext::timed must be set to,
or the status the interaction terminates with.
The window is consumed either way — every outcome here terminates the transaction, and a window that survived would let one Timed Request pay for a second request later.
§Errors
Status::Timeout when the window expired, Status::TimedRequestMismatch when the
flag and the window disagree.
Sourcepub fn close(&mut self, session: Option<SessionId>, exchange: ExchangeId)
pub fn close(&mut self, session: Option<SessionId>, exchange: ExchangeId)
Closes the window on an exchange without applying any rule.
For the case where the exchange itself ends — the session closed, the client vanished — rather than a request arriving on it.
Sourcepub fn close_session(&mut self, session: Option<SessionId>)
pub fn close_session(&mut self, session: Option<SessionId>)
Drops every window of a session, for when the session closes.
Sourcepub fn reap(&mut self, now: Instant) -> usize
pub fn reap(&mut self, now: Instant) -> usize
Drops every window whose deadline has passed, returning how many went.
Optional: TimedWindows::open already reclaims expired slots when it needs one. A
window dropped here can no longer produce Status::Timeout, only
Status::TimedRequestMismatch, since the evidence that there was a window is gone.
Sourcepub fn next_deadline(&self) -> Option<Instant>
pub fn next_deadline(&self) -> Option<Instant>
The earliest deadline, for a caller that wants to schedule a reap.