Trait BulkTerminate

Source
pub trait BulkTerminate: Send + Sync {
    // Required method
    fn terminate_all<'life0, 'async_trait>(
        &'life0 self,
        timeout: Duration,
        max_in_flight: usize,
    ) -> Pin<Box<dyn Future<Output = TerminateSummary> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for managers that can terminate many child units in bulk.

Implementors provide a concurrency-bounded, graceful shutdown over all currently tracked children (polite stop → wait → forceful stop), returning a summary of outcomes. The exact stop/kill semantics are manager-specific: for example, an OS-process manager might send signals, while an in-process manager might drain/abort tasks.

Required Methods§

Source

fn terminate_all<'life0, 'async_trait>( &'life0 self, timeout: Duration, max_in_flight: usize, ) -> Pin<Box<dyn Future<Output = TerminateSummary> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gracefully terminate all known children.

Initiates a polite shutdown for each child, waits up to timeout for completion, then escalates to a forceful stop for any that remain. Work may be done in parallel, capped by max_in_flight. The returned TerminateSummary reports how many children were attempted, succeeded, and failed.

Implementation notes:

  • “Polite shutdown” and “forceful stop” are intentionally abstract. Implementors should map these to whatever semantics they control (e.g., proc-level drain/abort, RPCs, OS signals).
  • The operation must be idempotent and tolerate races with concurrent termination or external exits.
§Parameters
  • timeout: Per-child grace period before escalation to a forceful stop.
  • max_in_flight: Upper bound on concurrent terminations (≥
    1. to prevent resource spikes (I/O, CPU, file descriptors, etc.).

Implementors§