pub struct AccountEventSink { /* private fields */ }Expand description
Account-wide durable change-feed sink. Construct once per [AppState].
Implementations§
Source§impl AccountEventSink
impl AccountEventSink
Sourcepub fn new(events_dir: PathBuf) -> Result<Arc<AccountEventSink>, Error>
pub fn new(events_dir: PathBuf) -> Result<Arc<AccountEventSink>, Error>
Open the journal (recovering the max seq) and spawn the writer task.
Sourcepub fn record(&self, session_id: Option<&str>, event: &AgentEvent)
pub fn record(&self, session_id: Option<&str>, event: &AgentEvent)
Record an event onto the change feed, if it is durable.
session_id is the caller’s known session context (forwarders are
per-session) and wins over AgentEvent::session_id so terminal events
(Complete/Cancelled/Error, which carry no id) still route to the
right session. Never blocks: ephemeral events are filtered out before
any clone, then the durable event is try_send-ed.
Sourcepub fn inbox(&self) -> Sender<(Option<String>, AgentEvent)>
pub fn inbox(&self) -> Sender<(Option<String>, AgentEvent)>
Clone of the writer inbox, for dependency-free callers (the engine
forwarder) that cannot reference AppState/this type’s record. Such
callers must filter with AgentEvent::is_durable_change before
sending so ephemeral token traffic never crosses the channel.
Sourcepub fn subscribe(&self) -> Receiver<Arc<ChangeEvent>>
pub fn subscribe(&self) -> Receiver<Arc<ChangeEvent>>
Subscribe to the live account tail. Subscribe before reading the
journal on the /stream path so the replay→live handoff cannot gap.
Sourcepub fn events_dir(&self) -> &Path
pub fn events_dir(&self) -> &Path
Journal directory, for stateless replay reads.
Sourcepub fn latest_seq(&self) -> u64
pub fn latest_seq(&self) -> u64
Last-assigned seq (0 if none yet).
Sourcepub fn dropped_count(&self) -> u64
pub fn dropped_count(&self) -> u64
Number of events dropped due to a full inbox (diagnostics).