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).
Fields are Option so that shutdown can take them without a
move-out-of-Drop conflict, and so the Drop impl can abort any task not yet drained.
tx is declared before handle to ensure the channel is closed before the handle is
dropped, which allows the background task to exit cleanly when Drop fires.
Implementations§
Source§impl RetrievalFailureLogger
impl RetrievalFailureLogger
Sourcepub fn new(
sqlite: SqliteStore,
channel_capacity: usize,
batch_size: usize,
flush_interval: Duration,
retention_days: u32,
) -> Self
pub fn new( sqlite: SqliteStore, channel_capacity: usize, batch_size: usize, flush_interval: Duration, retention_days: u32, ) -> Self
Spawn the background writer task 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).
Trait Implementations§
Source§impl Drop for RetrievalFailureLogger
impl Drop for RetrievalFailureLogger
Source§fn drop(&mut self)
fn drop(&mut self)
Abort the background writer task on drop.
For a clean drain (flushing queued records) call RetrievalFailureLogger::shutdown
explicitly before dropping. This impl ensures the task is not silently detached.
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
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