pub trait ApiHandler:
Send
+ Sync
+ 'static {
// Required methods
fn submit_task<'life0, 'async_trait>(
&'life0 self,
spec: TaskSpec,
) -> Pin<Box<dyn Future<Output = Result<TaskId, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_task_status<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<Option<Task>, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn query_tasks<'life0, 'async_trait>(
&'life0 self,
query: TaskQuery,
) -> Pin<Box<dyn Future<Output = Result<TaskPage<Task>, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list_task_runs<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<Vec<TaskRun>, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_task<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<(), ApiError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn stream_task_logs<'life0, 'life1, 'async_trait>(
&'life0 self,
_id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<OutputEventStream, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Task execution API handler.
§Also
SupervisorApiAdapterready-to-use implementation.ApiErrorerror type returned by all methods.
This trait abstracts the backend implementation, allowing users to:
- Use the provided
SupervisorApiAdapter - Implement custom handlers with additional logic (auth, rate limiting, etc.)
§API surface
| Method | HTTP | gRPC |
|---|---|---|
submit_task | POST /api/v1/tasks | SubmitTask |
get_task_status | GET /api/v1/tasks/{id} | GetTaskStatus |
query_tasks | GET /api/v1/tasks | ListTasks |
list_task_runs | GET /api/v1/tasks/{id}/runs | ListTaskRuns |
delete_task | DELETE /api/v1/tasks/{id} | DeleteTask |
stream_task_logs | GET /api/v1/tasks/{id}/logs | StreamTaskLogs |
Required Methods§
Sourcefn submit_task<'life0, 'async_trait>(
&'life0 self,
spec: TaskSpec,
) -> Pin<Box<dyn Future<Output = Result<TaskId, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn submit_task<'life0, 'async_trait>(
&'life0 self,
spec: TaskSpec,
) -> Pin<Box<dyn Future<Output = Result<TaskId, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Submit a new task for execution.
Sourcefn get_task_status<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<Option<Task>, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_task_status<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<Option<Task>, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get current status of a task by ID.
Sourcefn query_tasks<'life0, 'async_trait>(
&'life0 self,
query: TaskQuery,
) -> Pin<Box<dyn Future<Output = Result<TaskPage<Task>, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn query_tasks<'life0, 'async_trait>(
&'life0 self,
query: TaskQuery,
) -> Pin<Box<dyn Future<Output = Result<TaskPage<Task>, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Query tasks with combined filters and pagination.
Supports filtering by slot and/or status simultaneously, with offset/limit pagination. Returns a page with total count.
Sourcefn list_task_runs<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<Vec<TaskRun>, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_task_runs<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<Vec<TaskRun>, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
List execution history for a specific task (oldest first).
Sourcefn delete_task<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<(), ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_task<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<(), ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stop a task and purge its run history.
Idempotent:
returns Ok(()) whether the task is currently registered on the agent.
Errors only on supervisor cancellation failures (timeout, internal error).
Provided Methods§
Sourcefn stream_task_logs<'life0, 'life1, 'async_trait>(
&'life0 self,
_id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<OutputEventStream, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stream_task_logs<'life0, 'life1, 'async_trait>(
&'life0 self,
_id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<OutputEventStream, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Subscribe to the live-tail stream of stdout/stderr lines for a task.
Returns an OutputEventStream that yields OutputEvents in real time.
The stream covers all subsequent runs of the task (multi-run merge) and ends when the task is fully terminal and evicted.