Skip to main content

TaskBroker

Trait TaskBroker 

Source
pub trait TaskBroker: Send + Sync {
    // Required methods
    fn submit(
        &self,
        task: AgentTask,
    ) -> impl Future<Output = Result<String>> + Send;
    fn status(
        &self,
        task_id: &str,
    ) -> impl Future<Output = Result<TaskStatus>> + Send;
    fn receive(&self) -> impl Future<Output = Result<Option<AgentTask>>> + Send;
    fn complete(
        &self,
        task_id: &str,
        result: TaskResult,
    ) -> impl Future<Output = Result<()>> + Send;
    fn fail(
        &self,
        task_id: &str,
        error: String,
    ) -> impl Future<Output = Result<()>> + Send;
}
Expand description

Trait for distributing agent tasks across workers.

Implement this for your message broker (AWS SQS, Google Pub/Sub, Azure Service Bus, Redis, NATS, RabbitMQ, etc.) to enable multi-process agent execution.

Required Methods§

Source

fn submit(&self, task: AgentTask) -> impl Future<Output = Result<String>> + Send

Submits a task for execution. Returns the task ID.

Source

fn status( &self, task_id: &str, ) -> impl Future<Output = Result<TaskStatus>> + Send

Queries the current status of a task.

Source

fn receive(&self) -> impl Future<Output = Result<Option<AgentTask>>> + Send

Blocks until a task is available and returns it. Returns None if the broker is closed.

Source

fn complete( &self, task_id: &str, result: TaskResult, ) -> impl Future<Output = Result<()>> + Send

Marks a task as completed with the given result.

Source

fn fail( &self, task_id: &str, error: String, ) -> impl Future<Output = Result<()>> + Send

Marks a task as failed with an error message.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§