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§
Sourcefn submit(&self, task: AgentTask) -> impl Future<Output = Result<String>> + Send
fn submit(&self, task: AgentTask) -> impl Future<Output = Result<String>> + Send
Submits a task for execution. Returns the task ID.
Sourcefn status(
&self,
task_id: &str,
) -> impl Future<Output = Result<TaskStatus>> + Send
fn status( &self, task_id: &str, ) -> impl Future<Output = Result<TaskStatus>> + Send
Queries the current status of a task.
Sourcefn receive(&self) -> impl Future<Output = Result<Option<AgentTask>>> + Send
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.