Skip to main content

ApiHandler

Trait ApiHandler 

Source
pub trait ApiHandler:
    Send
    + Sync
    + 'static {
    // Required methods
    fn create_task<'life0, 'async_trait>(
        &'life0 self,
        manifest: TaskManifest,
    ) -> Pin<Box<dyn Future<Output = Result<Task, ApiError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn apply_task<'life0, 'async_trait>(
        &'life0 self,
        manifest: TaskManifest,
        preconditions: WritePreconditions,
    ) -> Pin<Box<dyn Future<Output = Result<Task, ApiError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_task<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'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 watch_tasks<'life0, 'async_trait>(
        &'life0 self,
        filter: TaskFilter,
        resource_version: Option<String>,
    ) -> Pin<Box<dyn Future<Output = Result<TaskWatchEventStream, 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,
        preconditions: WritePreconditions,
    ) -> Pin<Box<dyn Future<Output = Result<(), 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;
}
Expand description

Transport-independent task API.

The trait covers desired writes, current reads, collection watches, run history, deletion, and live output.

Implementations must not expose the built-in Embedded workload. Both transports check that boundary before encoding a response.

§Operations

MethodHTTPgRPC
create_taskPOST /apis/solti.io/v1/tasksCreateTask
apply_taskPUT /apis/solti.io/v1/tasks/{name}ApplyTask
get_taskGET /apis/solti.io/v1/tasks/{name}GetTask
query_tasksGET /apis/solti.io/v1/tasksListTasks
watch_tasksGET /apis/solti.io/v1/tasks?watch=trueWatchTasks
list_task_runsGET /apis/solti.io/v1/tasks/{name}/runsListTaskRuns
delete_taskDELETE /apis/solti.io/v1/tasks/{name}DeleteTask
stream_task_logsGET /apis/solti.io/v1/tasks/{name}/logsStreamTaskLogs

§See Also

  • SupervisorApiAdapter implements this trait for solti-core.
  • ApiError defines the shared transport error categories.

Required Methods§

Source

fn create_task<'life0, 'async_trait>( &'life0 self, manifest: TaskManifest, ) -> Pin<Box<dyn Future<Output = Result<Task, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates one named task resource.

The bundled adapter returns committed desired state immediately. Reconciliation continues in the background. Its result appears in status.conditions[type=Reconciled].

§Errors

The bundled adapter returns:

Later reconciliation failures are status updates. They are not create errors.

Source

fn apply_task<'life0, 'async_trait>( &'life0 self, manifest: TaskManifest, preconditions: WritePreconditions, ) -> Pin<Box<dyn Future<Output = Result<Task, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates or updates the task addressed by metadata.name.

Empty preconditions make this an upsert. Any precondition requires an existing matching resource.

§Errors

The bundled adapter can return the errors from create_task. It can also return:

Source

fn get_task<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 TaskId, ) -> Pin<Box<dyn Future<Output = Result<Option<Task>, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns the current task resource with this name.

None means that no public task has this name.

§Errors

The bundled adapter does not return an error. A custom implementation can return any ApiError.

Source

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,

Returns one filtered task page.

The returned page must match the query filters and limit. Its continuation must describe the same snapshot and filter. The transports reject an inconsistent page as ApiError::Internal.

§Errors

The bundled adapter returns:

Source

fn watch_tasks<'life0, 'async_trait>( &'life0 self, filter: TaskFilter, resource_version: Option<String>, ) -> Pin<Box<dyn Future<Output = Result<TaskWatchEventStream, ApiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Watches changes to tasks that match the filter.

With the bundled adapter, an absent resource version or "0" first emits current matches as Added. A specific version replays newer retained changes. Both forms then continue with live changes.

§Errors

The bundled adapter returns ApiError::ResourceVersionExpired when the requested position is no longer retained.

The stream can later yield the same error when it falls behind. That error is terminal.

Source

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,

Lists one task’s execution attempts from oldest to newest.

§Errors

The bundled adapter returns ApiError::TaskNotFound when the task is not public or does not exist.

Source

fn delete_task<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 TaskId, preconditions: WritePreconditions, ) -> Pin<Box<dyn Future<Output = Result<(), ApiError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Stops and removes one task and its run history.

§Errors

The bundled adapter returns:

Source

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,

Subscribes to one task’s live output.

The stream is lossy and has no replay. It can cover later attempts of the same task generation. Run boundary events are best-effort observations. They are not ordering barriers for output chunks.

The bundled adapter pins the stream to the generation visible when this method is called.

§Errors

The bundled adapter returns ApiError::TaskNotFound when no public live output channel exists for this task.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§