pub struct EventReplay {
pub max_per_run: usize,
pub max_runs: usize,
/* private fields */
}Expand description
Bounded per-run event replay buffer. Closes a broadcast race: a
client that calls POST /api/v1/scan and then opens the
WebSocket would miss
RunStarted (and possibly the first few RepoStarted/RepoFailed)
frames because tokio’s broadcast::Sender does not replay history.
events_ws reads back the snapshot here before joining the live
stream so the LiveScanView always sees the run’s lifecycle from the
start.
Events that lack a run_id (e.g. plain heartbeats) are not buffered
because there is nothing for a subscriber to scope to.
Eviction is least-recently-touched: the side order deque tracks
run ids with the most recently pushed-into run at the back. When a
new run needs admission past max_runs, the front (oldest activity)
is evicted.
Fields§
§max_per_run: usizeHard cap on events stored per run. The LiveScanView acceptance set is small (one RunStarted + N RepoStarted/RepoFinished pairs + RunFinished). 128 frames covers ~60 repos before the head is dropped, which is more than the static-pass budget.
max_runs: usizeCap on tracked runs. Past this we evict the least-recently- touched tracked run. 16 covers the realistic concurrent- LiveScanView count.
Implementations§
Source§impl EventReplay
impl EventReplay
pub fn new() -> Self
Sourcepub async fn push(&self, event: &AgentEvent)
pub async fn push(&self, event: &AgentEvent)
Append an event to the per-run buffer. No-op for events that do
not carry a run_id.
Sourcepub async fn snapshot(&self, run_id: &str) -> Vec<AgentEvent>
pub async fn snapshot(&self, run_id: &str) -> Vec<AgentEvent>
Snapshot every buffered event for run_id. Cheap clone.
Sourcepub async fn tracked_runs(&self) -> usize
pub async fn tracked_runs(&self) -> usize
Number of currently tracked runs. Used in tests; cheap.
Trait Implementations§
Source§impl Debug for EventReplay
impl Debug for EventReplay
Auto Trait Implementations§
impl !Freeze for EventReplay
impl !RefUnwindSafe for EventReplay
impl Send for EventReplay
impl Sync for EventReplay
impl Unpin for EventReplay
impl UnsafeUnpin for EventReplay
impl !UnwindSafe for EventReplay
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§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>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§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.Source§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.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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