use async_trait::async_trait;
use crate::error::WorkflowResult;
use crate::instance::{PageRequest, PageResult, Task};
#[async_trait]
pub trait TaskRepository: Send + Sync + 'static {
async fn create(&self, task: &Task) -> WorkflowResult<()>;
async fn get(&self, task_id: &str) -> WorkflowResult<Option<Task>>;
async fn update(&self, task: &Task) -> WorkflowResult<()>;
async fn invalidate_by_instance(&self, instance_id: &str) -> WorkflowResult<u64>;
async fn list_pending_by_candidate(
&self,
candidate: &str,
page: PageRequest,
) -> WorkflowResult<PageResult<Task>>;
async fn list_by_instance(&self, instance_id: &str) -> WorkflowResult<Vec<Task>>;
}