pub struct MsgBatcher { /* private fields */ }Implementations§
Source§impl MsgBatcher
impl MsgBatcher
Sourcepub async fn new(database_url: &str) -> Result<Self, BatcherError>
pub async fn new(database_url: &str) -> Result<Self, BatcherError>
Create new batcher with PostgreSQL connection string
Sourcepub fn with_batch_size(self, size: usize) -> Self
pub fn with_batch_size(self, size: usize) -> Self
Configure batch size (default: 5000)
Sourcepub fn with_flush_interval(self, seconds: u64) -> Self
pub fn with_flush_interval(self, seconds: u64) -> Self
Configure flush interval in seconds (default: 5)
Sourcepub fn with_max_buffer(self, size: usize) -> Self
pub fn with_max_buffer(self, size: usize) -> Self
Configure max buffer size (default: 10000)
Sourcepub async fn append(&self, msg: Message) -> Result<(), BatcherError>
pub async fn append(&self, msg: Message) -> Result<(), BatcherError>
Append message to buffer (non-blocking, ~microseconds)
Sourcepub async fn flush(&self) -> Result<(), BatcherError>
pub async fn flush(&self) -> Result<(), BatcherError>
Manually flush all pending messages
Sourcepub async fn run_background(&self) -> Result<(), BatcherError>
pub async fn run_background(&self) -> Result<(), BatcherError>
Background worker - call this in your main function
Sourcepub async fn shutdown(&self) -> Result<(), BatcherError>
pub async fn shutdown(&self) -> Result<(), BatcherError>
Stop background worker gracefully
Sourcepub async fn buffer_size(&self) -> usize
pub async fn buffer_size(&self) -> usize
Get current buffer size
Auto Trait Implementations§
impl !RefUnwindSafe for MsgBatcher
impl !UnwindSafe for MsgBatcher
impl Freeze for MsgBatcher
impl Send for MsgBatcher
impl Sync for MsgBatcher
impl Unpin for MsgBatcher
impl UnsafeUnpin for MsgBatcher
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
Mutably borrows from an owned value. Read more