pub struct RetrievalFailureLogger { /* private fields */ }Expand description
Async background writer that batches retrieval failure records to SQLite.
Construct with RetrievalFailureLogger::new and call RetrievalFailureLogger::log
from the recall hot path. Records are sent via a bounded channel; if the channel is
full the record is silently dropped (zero hot-path latency, per INV-1).
The background writer task is registered with TaskSupervisor for lifecycle
visibility and graceful shutdown. Call shutdown for a clean drain.
Implementations§
Source§impl RetrievalFailureLogger
impl RetrievalFailureLogger
Sourcepub fn new(
sqlite: SqliteStore,
channel_capacity: usize,
batch_size: usize,
flush_interval: Duration,
retention_days: u32,
supervisor: &TaskSupervisor,
) -> Self
pub fn new( sqlite: SqliteStore, channel_capacity: usize, batch_size: usize, flush_interval: Duration, retention_days: u32, supervisor: &TaskSupervisor, ) -> Self
Spawn the background writer task under supervisor and return a logger handle.
batch_size records are flushed at once, or after flush_interval elapses,
whichever comes first. Old records are purged every CLEANUP_FLUSH_INTERVAL
batch flushes according to retention_days.
Sourcepub fn log(&self, record: RetrievalFailureRecord)
pub fn log(&self, record: RetrievalFailureRecord)
Queue a retrieval failure record for async persistence.
Both query_text (512 chars) and error_context (256 chars) are truncated
before enqueueing to bound in-channel memory usage (INV-3). If the channel is
full the record is dropped and a debug message is emitted (INV-1).
Sourcepub async fn shutdown(self)
pub async fn shutdown(self)
Drain queued records and wait for the writer to flush before returning.
Drops the sender so writer_task exits its receive loop, flushes the
remaining batch, and fires the done notify. TaskSupervisor::shutdown_all
should be called after this to clean up the registry entry.
Auto Trait Implementations§
impl Freeze for RetrievalFailureLogger
impl RefUnwindSafe for RetrievalFailureLogger
impl Send for RetrievalFailureLogger
impl Sync for RetrievalFailureLogger
impl Unpin for RetrievalFailureLogger
impl UnsafeUnpin for RetrievalFailureLogger
impl UnwindSafe for RetrievalFailureLogger
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request