use crate::{error::OrchError, id::*, operator::OperatorInput, operator::OperatorOutput};
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
#[async_trait]
pub trait Orchestrator: Send + Sync {
async fn dispatch(
&self,
agent: &AgentId,
input: OperatorInput,
) -> Result<OperatorOutput, OrchError>;
async fn dispatch_many(
&self,
tasks: Vec<(AgentId, OperatorInput)>,
) -> Vec<Result<OperatorOutput, OrchError>>;
async fn signal(
&self,
target: &WorkflowId,
signal: crate::effect::SignalPayload,
) -> Result<(), OrchError>;
async fn query(
&self,
target: &WorkflowId,
query: QueryPayload,
) -> Result<serde_json::Value, OrchError>;
}
#[non_exhaustive]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QueryPayload {
pub query_type: String,
pub params: serde_json::Value,
}
impl QueryPayload {
pub fn new(query_type: impl Into<String>, params: serde_json::Value) -> Self {
Self {
query_type: query_type.into(),
params,
}
}
}