kotoba_server_workflow/
workflow.rs1#[cfg(feature = "workflow")]
4pub use kotoba_workflow_core::{
5 WorkflowEngine,
6 WorkflowExecutionId,
7 WorkflowIR,
8 WorkflowExecution,
9 StartWorkflowResponse,
10};
11
12#[cfg(feature = "workflow")]
13use async_trait::async_trait;
14
15#[cfg(feature = "workflow")]
17#[async_trait]
18pub trait WorkflowEngineInterface: Send + Sync {
19 async fn start_workflow(
20 &self,
21 workflow: &WorkflowIR,
22 context: serde_json::Value,
23 ) -> Result<WorkflowExecutionId, kotoba_errors::KotobaError>;
24
25 async fn get_execution(
26 &self,
27 execution_id: &WorkflowExecutionId,
28 ) -> Result<Option<WorkflowExecution>, kotoba_errors::KotobaError>;
29
30 async fn list_executions(&self) -> Result<Vec<WorkflowExecution>, kotoba_errors::KotobaError>;
31
32 async fn cancel_execution(
33 &self,
34 execution_id: &WorkflowExecutionId,
35 ) -> Result<(), kotoba_errors::KotobaError>;
36}
37
38#[cfg(feature = "workflow")]
39#[async_trait]
40impl WorkflowEngineInterface for WorkflowEngine {
41 async fn start_workflow(
42 &self,
43 workflow: &WorkflowIR,
44 context: serde_json::Value,
45 ) -> Result<WorkflowExecutionId, kotoba_errors::KotobaError> {
46 self.start_workflow(workflow, context).await
47 }
48
49 async fn get_execution(
50 &self,
51 execution_id: &WorkflowExecutionId,
52 ) -> Result<Option<WorkflowExecution>, kotoba_errors::KotobaError> {
53 self.get_execution(execution_id).await
54 }
55
56 async fn list_executions(&self) -> Result<Vec<WorkflowExecution>, kotoba_errors::KotobaError> {
57 Err(kotoba_errors::KotobaError::Execution("list_executions not implemented".to_string()))
59 }
60
61 async fn cancel_execution(
62 &self,
63 execution_id: &WorkflowExecutionId,
64 ) -> Result<(), kotoba_errors::KotobaError> {
65 Err(kotoba_errors::KotobaError::Execution("cancel_execution not implemented".to_string()))
67 }
68}