commit_bridge/engine.rs
1//! Interface definitions for async engines.
2
3use async_trait::async_trait;
4use tokio_util::task::TaskTracker;
5
6use tracing::info;
7
8/// Defines the interface of an asynchronous background running engine.
9#[async_trait]
10pub trait AsyncEngine: Send + Sync + 'static {
11 /// The core execution loop of the engine.
12 async fn run(&self);
13}
14
15/// Starts the engine by spawning it in a new task.
16pub fn start_engine(engine: Box<dyn AsyncEngine>, message: &str, tracker: &TaskTracker) {
17 info!(message);
18 tracker.spawn(async move {
19 engine.run().await;
20 });
21}