Skip to main content

rustvello_core/
runner.rs

1use async_trait::async_trait;
2
3use rustvello_proto::identifiers::RunnerId;
4
5use crate::error::RustvelloResult;
6
7/// Runner interface — the task execution engine.
8///
9/// Mirrors pynenc's `BaseRunner`. A runner:
10/// 1. Polls the broker for queued invocations
11/// 2. Loads invocation data from the state backend
12/// 3. Executes the task function
13/// 4. Stores results and updates status
14#[async_trait]
15pub trait Runner: Send + Sync {
16    /// Get this runner's unique identifier.
17    fn runner_id(&self) -> &RunnerId;
18
19    /// Human-readable runner class name (e.g., "PersistentTokioRunner").
20    fn runner_cls(&self) -> &str;
21
22    /// Maximum number of parallel execution slots.
23    fn max_parallel_slots(&self) -> usize;
24
25    /// Get runner_ids of currently active workers.
26    fn active_worker_ids(&self) -> Vec<RunnerId>;
27
28    /// Start the runner's main execution loop.
29    /// This is a blocking call that runs until shutdown.
30    async fn run(&self) -> RustvelloResult<()>;
31
32    /// Perform a single iteration of the runner loop.
33    /// Returns `true` if work was done, `false` if idle.
34    async fn run_one(&self) -> RustvelloResult<bool>;
35
36    /// Graceful shutdown signal.
37    async fn shutdown(&self) -> RustvelloResult<()>;
38
39    /// Send a heartbeat to indicate the runner is alive.
40    async fn heartbeat(&self) -> RustvelloResult<()>;
41}