summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/orchestrator.rs
blob: 5cbca08f6bc2fd34d77febe65764b501af4e2974 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use std::path::PathBuf;
use std::sync::RwLock;
use std::sync::Arc;

use anyhow::Result;
use typed_builder::TypedBuilder;
use diesel::PgConnection;

use crate::endpoint::EndpointManagerConfiguration;
use crate::endpoint::EndpointScheduler;
use crate::job::JobSet;
use crate::job::RunnableJob;
use crate::log::LogItem;
use crate::filestore::StagingStore;
use crate::filestore::ReleaseStore;

pub struct Orchestrator {
    scheduler: EndpointScheduler,
    staging_store: Arc<RwLock<StagingStore>>,
    release_store: Arc<RwLock<ReleaseStore>>,
    jobsets: Vec<JobSet>,
    database: PgConnection,
}

#[derive(TypedBuilder)]
pub struct OrchestratorSetup {
    ep_cfg: Vec<EndpointManagerConfiguration>,
    staging_store: Arc<RwLock<StagingStore>>,
    release_store: Arc<RwLock<ReleaseStore>>,
    jobsets: Vec<JobSet>,
    database: PgConnection,
}

impl OrchestratorSetup {
    pub async fn setup(self) -> Result<Orchestrator> {
        let scheduler = EndpointScheduler::setup(self.ep_cfg, self.staging_store.clone()).await?;

        Ok(Orchestrator {
            scheduler:      scheduler,
            staging_store:  self.staging_store,
            release_store:  self.release_store,
            jobsets:        self.jobsets,
            database:       self.database,
        })
    }
}

impl Orchestrator {

    pub async fn run(self) -> Result<()> {
        unimplemented!()
    }

}