Add an event to the batch buffer. Returns true if the batch should be flushed (size threshold reached).
(&self, event: a3s_ahp::AhpEvent)
| 443 | /// |
| 444 | /// Returns true if the batch should be flushed (size threshold reached). |
| 445 | pub async fn add_to_batch(&self, event: a3s_ahp::AhpEvent) -> bool { |
| 446 | let should_flush = { |
| 447 | let mut buffer = write_or_recover(&self.batch_buffer); |
| 448 | buffer.push(event); |
| 449 | buffer.len() >= self.batch_size |
| 450 | }; |
| 451 | |
| 452 | if should_flush { |
| 453 | self.flush_batch().await; |
| 454 | } |
| 455 | |
| 456 | should_flush |
| 457 | } |
| 458 | |
| 459 | /// Flush the batch buffer and send all events. |
| 460 | pub async fn flush_batch(&self) { |
no test coverage detected