Execute the batcher until `cancellation` is cancelled.
(
self,
metrics_enabled: bool,
cancellation: CancellationToken,
)
| 428 | |
| 429 | /// Execute the batcher until `cancellation` is cancelled. |
| 430 | pub async fn exec( |
| 431 | self, |
| 432 | metrics_enabled: bool, |
| 433 | cancellation: CancellationToken, |
| 434 | ) -> eyre::Result<()> { |
| 435 | let config = self.into_config(metrics_enabled)?; |
| 436 | let rt = TokioRuntime::with_token(cancellation.clone()); |
| 437 | |
| 438 | let setup = BatcherService::new(config).setup(rt); |
| 439 | let ready = tokio::select! { |
| 440 | ready = setup => ready?, |
| 441 | () = cancellation.cancelled() => return Ok(()), |
| 442 | }; |
| 443 | ready.run().await |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | #[cfg(test)] |