|
1 | | -use crate::traversal::navigation::App; |
2 | | -use dovahkiin::types::Id; |
3 | | -use parking_lot::Mutex; |
4 | 1 | use serde::{Deserialize, Serialize}; |
5 | | -use std::sync::Arc; |
6 | 2 |
|
7 | 3 | pub mod logger; |
8 | | -pub mod service; |
9 | 4 |
|
10 | 5 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] |
11 | 6 | pub struct JobId { |
12 | 7 | pub coordinator_server_id: u64, |
13 | 8 | pub coordinator_job_id: u64, |
14 | 9 | } |
15 | 10 |
|
16 | | -#[derive(Debug, Clone, Serialize, Deserialize)] |
17 | | -pub struct JobReport { |
18 | | - pub status: JobStatus, |
19 | | - pub result: Vec<u8>, |
20 | | -} |
21 | | - |
22 | | -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] |
23 | | -pub enum JobStatus { |
24 | | - Created, |
25 | | - Initialized, |
26 | | - Running, |
27 | | - Finished, |
28 | | - Failed, |
29 | | -} |
30 | | - |
31 | | -pub struct Job { |
32 | | - pub job_id: JobId, |
33 | | - pub app: App, |
34 | | - pub config: Vec<u8>, |
35 | | - pub report: Arc<Mutex<JobReport>>, |
36 | | -} |
37 | | - |
38 | | -pub enum CollectiveResult { |
39 | | - Found(Vec<(Id, u64)>), |
40 | | - Continue(Vec<(Id, u64, f32)>), |
41 | | - Error(Vec<(Id, u64, String)>), |
42 | | - NotFound, |
43 | | -} |
44 | | - |
45 | | -impl JobReport { |
46 | | - pub fn new() -> Self { |
47 | | - Self { |
48 | | - status: JobStatus::Created, |
49 | | - result: vec![], |
50 | | - } |
51 | | - } |
52 | | - |
53 | | - pub fn update_status(&mut self, status: JobStatus) { |
54 | | - self.status = status; |
55 | | - } |
56 | | - |
57 | | - pub fn update_findings(&mut self, findings: Vec<u8>) { |
58 | | - self.result = findings; |
59 | | - } |
60 | | -} |
61 | | - |
62 | | -pub fn initialize_job_run(report: &Arc<Mutex<JobReport>>) { |
63 | | - report.lock().update_status(JobStatus::Running); |
64 | | -} |
65 | | - |
66 | 11 | impl JobId { |
67 | 12 | pub fn new(coordinator_server_id: u64, coordinator_job_id: u64) -> Self { |
68 | 13 | Self { |
|
0 commit comments