Skip to content

Commit 5408aa0

Browse files
ischeinkmanamunra
andauthored
chore: allow external Buffer flushability checking (#101)
* Added `Buffer::check_can_flush` * Remove transaction logic from the flush fn --------- Co-authored-by: Adam Cimarosti <cimarosti@gmail.com>
1 parent 00e5a0f commit 5408aa0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

questdb-rs/src/ingress/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,15 @@ impl Buffer {
689689
}
690690
}
691691

692+
/// Checks if this buffer is ready to be flushed to a sender via one of the
693+
/// [`Sender::flush`] functions. An [`Ok`] value indicates that the buffer
694+
/// is ready to be flushed via a [`Sender`] while an [`Err`] will contain a
695+
/// message indicating why this [`Buffer`] cannot be flushed at the moment.
696+
#[inline(always)]
697+
pub fn check_can_flush(&self) -> Result<()> {
698+
self.check_op(Op::Flush)
699+
}
700+
692701
#[inline(always)]
693702
fn validate_max_name_len(&self, name: &str) -> Result<()> {
694703
if name.len() > self.max_name_len {
@@ -2585,7 +2594,7 @@ impl Sender {
25852594
"Could not flush buffer: not connected to database."
25862595
));
25872596
}
2588-
buf.check_op(Op::Flush)?;
2597+
buf.check_can_flush()?;
25892598

25902599
if buf.len() > self.max_buf_size {
25912600
return Err(error::fmt!(

0 commit comments

Comments
 (0)