pub struct OutgoingQueue { /* private fields */ }Expand description
The outgoing HTTP request queue — see the module doc.
Implementations§
Source§impl OutgoingQueue
impl OutgoingQueue
Sourcepub fn new() -> Self
pub fn new() -> Self
Builds an empty queue — the brand-new-device case. A shell with an
existing store calls OutgoingQueue::load instead.
Sourcepub fn load<S: StateStore>(store: &S) -> Result<Self, StoreError>
pub fn load<S: StateStore>(store: &S) -> Result<Self, StoreError>
Rebuilds a queue from store’s durably-persisted pending requests.
See the module doc’s “Restart” section for exactly what survives
(enqueue order, lanes, flush epochs) and what doesn’t (in-flight
status, retry backoff).
Sourcepub fn discard_kind<S: StateStore>(
&mut self,
store: &mut S,
kind: OutgoingRequestKind,
) -> Result<(), StoreError>
pub fn discard_kind<S: StateStore>( &mut self, store: &mut S, kind: OutgoingRequestKind, ) -> Result<(), StoreError>
Drops every pending request of kind (from the queue and from
store). For a kind whose request carries no side effect a restart
could lose – /sync – so a core can mint a fresh one from current
state instead of replaying a stale one.
Sourcepub fn enqueue<S: StateStore + FlushEpoch>(
&mut self,
store: &mut S,
request: OutgoingRequest,
lane: Lane,
) -> Result<Option<FlushBatch>, StoreError>
pub fn enqueue<S: StateStore + FlushEpoch>( &mut self, store: &mut S, request: OutgoingRequest, lane: Lane, ) -> Result<Option<FlushBatch>, StoreError>
Enqueues request on lane, persisting it via
crate::store::StateStore::save_pending_request so it survives a
crash before ever being acknowledged. Idempotent on request.id:
enqueuing the same id twice (a duplicate dispatch) is a safe no-op
the second time — Ok(None) either because nothing was pending to
seal at the time, or because the id was already tracked; both cases
leave this queue and store unchanged from the first call’s
result, so callers never need to distinguish them.
Returns whatever FlushBatch store’s flush epoch forced open
(see FlushEpoch::seal_for_request) for the caller to hand a
shell — None if nothing was pending to seal.
Sourcepub fn releasable<S: FlushEpoch>(
&mut self,
store: &S,
now_ms: i64,
) -> Vec<OutgoingRequest>
pub fn releasable<S: FlushEpoch>( &mut self, store: &S, now_ms: i64, ) -> Vec<OutgoingRequest>
Every request currently safe to send, in enqueue order: releasable
means not already in flight, its lane currently has room (see the
module doc’s “Lanes” table), its flush epoch is satisfied
(FlushEpoch::is_released), and — for a request that has been
retried before — its backoff has elapsed as of now_ms. Every
returned request is marked in flight; a caller that fails to
execute one must eventually call OutgoingQueue::on_transport_error
(or OutgoingQueue::on_response) to release its lane again.
Sourcepub fn on_response<S: StateStore>(
&mut self,
store: &mut S,
request_id: &RequestId,
response: HttpResponseDescriptor,
now_ms: i64,
jitter: &mut dyn Jitter,
) -> Result<Option<ResponseOutcome>, StoreError>
pub fn on_response<S: StateStore>( &mut self, store: &mut S, request_id: &RequestId, response: HttpResponseDescriptor, now_ms: i64, jitter: &mut dyn Jitter, ) -> Result<Option<ResponseOutcome>, StoreError>
Feeds one HTTP response back in for request_id. Returns Ok(None)
if request_id is not (or no longer) pending — a duplicate or
stale response is safely ignored. See the module doc’s “Retry
policy” section for the exact status-code classification.
Sourcepub fn on_transport_error(
&mut self,
request_id: &RequestId,
now_ms: i64,
jitter: &mut dyn Jitter,
) -> Option<ResponseOutcome>
pub fn on_transport_error( &mut self, request_id: &RequestId, now_ms: i64, jitter: &mut dyn Jitter, ) -> Option<ResponseOutcome>
Feeds a transport-level failure back in (no response at all — a
timeout, a connection reset, …). Always a
ResponseOutcome::Retry with this queue’s own capped exponential
backoff. Returns None if request_id is not (or no longer)
pending.