use std::future::Future;
use std::pin::Pin;
use uuid::Uuid;
use crate::error::Result;
use crate::job::JobInfo;
use crate::workflow::WorkflowInfo;
pub trait JobDispatch: Send + Sync {
fn get_info(&self, job_type: &str) -> Option<JobInfo>;
fn dispatch_by_name(
&self,
job_type: &str,
args: serde_json::Value,
owner_subject: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>;
fn cancel(
&self,
job_id: Uuid,
reason: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + '_>>;
}
pub trait WorkflowDispatch: Send + Sync {
fn get_info(&self, workflow_name: &str) -> Option<WorkflowInfo>;
fn start_by_name(
&self,
workflow_name: &str,
input: serde_json::Value,
owner_subject: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>;
}