use async_trait::async_trait;
use crate::error::WorkflowResult;
use crate::instance::{FlowInstance, InstanceStatus, PageRequest, PageResult};
#[async_trait]
pub trait InstanceRepository: Send + Sync + 'static {
async fn create(&self, instance: &FlowInstance) -> WorkflowResult<()>;
async fn get(&self, instance_id: &str) -> WorkflowResult<Option<FlowInstance>>;
async fn update_with_version(
&self,
instance: &FlowInstance,
expected_version: u64,
) -> WorkflowResult<bool>;
async fn list_by_status(
&self,
status: InstanceStatus,
page: PageRequest,
) -> WorkflowResult<PageResult<FlowInstance>>;
async fn list_running(&self) -> WorkflowResult<Vec<FlowInstance>>;
async fn list_running_batch(&self, batch_size: usize) -> WorkflowResult<Vec<FlowInstance>>;
}