pub struct KernelEventLog<'conn> { /* private fields */ }Expand description
Append-only writer for the kernel_events table.
Maintains a monotone seq counter per KernelEventLog instance
(per-session / per-sidecar lifetime). The counter is not persisted
across restarts; callers that need stable cross-restart ordering should
use the SQLite id column (autoincrement) instead.
Implementations§
Source§impl<'conn> KernelEventLog<'conn>
impl<'conn> KernelEventLog<'conn>
Sourcepub fn new(db: &'conn Connection) -> KernelEventLog<'conn>
pub fn new(db: &'conn Connection) -> KernelEventLog<'conn>
Create a writer that shares the given (already-migrated) connection.
Call ensure_kernel_events_table before constructing this.
Starts seq at 0 — suitable for empty in-memory test DBs. Production
callers should prefer Self::with_next_seq after [peek_next_seq].
Sourcepub fn with_next_seq(
db: &'conn Connection,
next_seq: u64,
) -> KernelEventLog<'conn>
pub fn with_next_seq( db: &'conn Connection, next_seq: u64, ) -> KernelEventLog<'conn>
Resume appending after restart using the next free sequence number.
Sourcepub fn peek_next_seq(db: &Connection) -> Result<u64, Error>
pub fn peek_next_seq(db: &Connection) -> Result<u64, Error>
Next seq value to assign (max existing + 1, or 0 when empty).
Sourcepub fn append(&mut self, event: KernelEvent) -> Result<(), Error>
pub fn append(&mut self, event: KernelEvent) -> Result<(), Error>
Append one event. The ts_ms is the Unix time in milliseconds at
call time.
Sourcepub fn append_batch(
&mut self,
events: impl IntoIterator<Item = KernelEvent>,
) -> Result<(), Error>
pub fn append_batch( &mut self, events: impl IntoIterator<Item = KernelEvent>, ) -> Result<(), Error>
Append multiple events in a single transaction.
Sourcepub fn load_turn_events(
&self,
turn_id: &str,
) -> Result<Vec<KernelEventEnvelope>, Error>
pub fn load_turn_events( &self, turn_id: &str, ) -> Result<Vec<KernelEventEnvelope>, Error>
Load all events for a given turn_id in sequence order.
Used by Phase 3b replay and completeness verification tests.
Auto Trait Implementations§
impl<'conn> !RefUnwindSafe for KernelEventLog<'conn>
impl<'conn> !Send for KernelEventLog<'conn>
impl<'conn> !Sync for KernelEventLog<'conn>
impl<'conn> !UnwindSafe for KernelEventLog<'conn>
impl<'conn> Freeze for KernelEventLog<'conn>
impl<'conn> Unpin for KernelEventLog<'conn>
impl<'conn> UnsafeUnpin for KernelEventLog<'conn>
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>. Box<dyn Any> can
then be further downcast into Box<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>. Rc<Any> 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> 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