MCPcopy Create free account
hub / github.com/AI45Lab/Code / flush_batch

Method flush_batch

core/src/ahp/executor.rs:460–485  ·  view source on GitHub ↗

Flush the batch buffer and send all events.

(&self)

Source from the content-addressed store, hash-verified

458
459 /// Flush the batch buffer and send all events.
460 pub async fn flush_batch(&self) {
461 let events = {
462 let mut buffer = write_or_recover(&self.batch_buffer);
463 if buffer.is_empty() {
464 return;
465 }
466 std::mem::take(&mut *buffer)
467 };
468
469 if !events.is_empty() {
470 let now = std::time::SystemTime::now()
471 .duration_since(std::time::UNIX_EPOCH)
472 .unwrap()
473 .as_millis() as u64;
474 self.last_batch_flush.store(now, Ordering::Relaxed);
475
476 match self.client.send_batch(events).await {
477 Ok(_) => {
478 debug!("Batch sent successfully");
479 }
480 Err(e) => {
481 warn!("Batch send failed: {}", e);
482 }
483 }
484 }
485 }
486
487 /// Check if batch timeout has expired and flush if needed.
488 pub async fn check_batch_timeout(&self) {

Callers 5

add_to_batchMethod · 0.80
check_batch_timeoutMethod · 0.80
publish_agent_eventMethod · 0.80
publish_run_cancelledMethod · 0.80
fireMethod · 0.80

Calls 5

write_or_recoverFunction · 0.85
nowFunction · 0.85
storeMethod · 0.80
send_batchMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected