1
use std::fmt::Debug;
2

            
3
use async_trait::async_trait;
4

            
5
use crate::jobs::{manager::Manager, task::Id, traits::Executable, Job};
6

            
7
#[derive(Debug)]
8
pub struct ManagedJob<J, Key> {
9
    pub id: Id,
10
    pub job: J,
11
    pub manager: Manager<Key>,
12
    pub key: Option<Key>,
13
}
14

            
15
#[async_trait]
16
impl<J, Key> Executable for ManagedJob<J, Key>
17
where
18
    J: Job,
19
    Key: Clone + std::hash::Hash + Eq + Send + Sync + Debug + 'static,
20
{
21
198505
    async fn execute(&mut self) {
22
249065
        let result = self.job.execute().await;
23

            
24
198400
        self.manager
25
198400
            .job_completed(self.id, self.key.as_ref(), result)
26
1764
            .await;
27
198400
    }
28
}