struct DeliveryState {
deliveries: HashMap<DeliveryKey, Delivery>,
fallback_claims: HashMap<(String, Reason), i64>,
fallbacks: HashMap<String, FallbackDelivery>,
boundary_origins: VecDeque<(String, String, i64)>,
completed: HashMap<(String, Reason), i64>,
}Expand description
Deliveries and fallback claims, behind one lock so “who claimed this event first” is decided atomically.
Fields§
§deliveries: HashMap<DeliveryKey, Delivery>§fallback_claims: HashMap<(String, Reason), i64>Events the frontend’s hidden-reinjection fallback claimed: (block, reason) → when.
fallbacks: HashMap<String, FallbackDelivery>Re-deliveries srv composed for the frontend’s fallback, by
delivery_id, until the hidden message that sends one arrives.
boundary_origins: VecDeque<(String, String, i64)>Which block’s CLI wrote each compaction boundary, and when: (uuid,
block, ms), oldest first.
completed: HashMap<(String, Reason), i64>The newest hook delivery each (block, reason) finished: when it was
composed. Unlike deliveries it isn’t pruned, so a fallback deferred
behind a long turn still finds it. One entry per block and reason.
Implementations§
Source§impl DeliveryState
impl DeliveryState
fn prune(&mut self, now: i64)
fn fallback_claimed(&self, block_id: &str, reason: Reason) -> bool
Sourcefn hook_deliveries_mut(
&mut self,
block_id: &str,
reason: Reason,
now: i64,
since: i64,
) -> Vec<&mut Delivery>
fn hook_deliveries_mut( &mut self, block_id: &str, reason: Reason, now: i64, since: i64, ) -> Vec<&mut Delivery>
The hook’s deliveries of this event, newest first: inside the claim
window and created after since.
Sourcefn claim_fallback(
&mut self,
block_id: &str,
reason: Reason,
now: i64,
since: i64,
) -> FallbackClaim
fn claim_fallback( &mut self, block_id: &str, reason: Reason, now: i64, since: i64, ) -> FallbackClaim
The fallback’s atomic claim on an event. A Deliver for an unclaimed
event records the claim, so the hook’s parts for it come back empty.
Hook deliveries created at or before since belong to an earlier event.
fn record_boundary(&mut self, uuid: &str, block_id: &str, now: i64)
Sourcefn claim_boundary(
&mut self,
block_id: &str,
reason: Reason,
boundary_uuid: Option<&str>,
now: i64,
) -> FallbackClaim
fn claim_boundary( &mut self, block_id: &str, reason: Reason, boundary_uuid: Option<&str>, now: i64, ) -> FallbackClaim
A claim naming its compaction boundary. Only the block whose own CLI wrote the boundary may deliver: another block of the agent reads it from the shared transcript zone, and its CLI did not compact. A boundary no stdout here wrote (another srv instance’s) is not this block’s either. A hook delivery from before the block’s previous boundary was that compaction’s, not this one’s.
Sourcefn claim_event(
&mut self,
block_id: &str,
reason: Reason,
event_at: i64,
now: i64,
) -> FallbackClaim
fn claim_event( &mut self, block_id: &str, reason: Reason, event_at: i64, now: i64, ) -> FallbackClaim
A claim dated by its event: a fresh session, at its
agentmux_session_outcome frame’s timestamp (srv’s own clock). A
hook delivery composed after the event and finished is that event’s
however long ago, so a fallback deferred behind the session’s first
turn stands down even past CLAIM_WINDOW_MS. One from before it
was an earlier session’s and doesn’t count.
Sourcefn note_completed(&mut self, key: &DeliveryKey, created_ms: i64)
fn note_completed(&mut self, key: &DeliveryKey, created_ms: i64)
The hook finished a delivery: its notice went out.
Sourcefn take_over_from_hook(&mut self, block_id: &str, reason: Reason, now: i64)
fn take_over_from_hook(&mut self, block_id: &str, reason: Reason, now: i64)
The fallback gave up waiting for the hook: it delivers, and the hook’s unfinished delivery is closed so a late acknowledgement adds no second notice.
Trait Implementations§
Source§impl Default for DeliveryState
impl Default for DeliveryState
Source§fn default() -> DeliveryState
fn default() -> DeliveryState
Auto Trait Implementations§
impl Freeze for DeliveryState
impl RefUnwindSafe for DeliveryState
impl Send for DeliveryState
impl Sync for DeliveryState
impl Unpin for DeliveryState
impl UnsafeUnpin for DeliveryState
impl UnwindSafe for DeliveryState
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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