1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::sync::Arc;
pub use async_trait::async_trait;
pub use chrono::{DateTime, Utc};
use crate::case::CaseAssess;
use crate::flow::Flow;
use crate::task::{StageAssess, TaskAssess, TaskId};
pub type Error = Box<dyn std::error::Error + Sync + Send>;
#[async_trait]
pub trait JobReporter: Sync + Send {
async fn task(
&self,
task_id: Arc<dyn TaskId>,
flow: Arc<Flow>,
) -> Result<Box<dyn TaskReporter>, Error>;
}
#[async_trait]
pub trait TaskReporter: Sync + Send {
async fn stage(&self, stage_id: &str) -> Result<Box<dyn StageReporter>, Error>;
async fn start(&mut self, time: DateTime<Utc>) -> Result<(), Error>;
async fn end(&mut self, task_assess: &dyn TaskAssess) -> Result<(), Error>;
}
#[async_trait]
pub trait StageReporter: Sync + Send {
async fn start(&mut self, time: DateTime<Utc>) -> Result<(), Error>;
async fn report(&mut self, case_assess_vec: &Vec<Box<dyn CaseAssess>>) -> Result<(), Error>;
async fn end(&mut self, task_assess: &dyn StageAssess) -> Result<(), Error>;
}