Skip to main content

icebox/core/
framework.rs

1use std::sync::Arc;
2use tokio::sync::Mutex;
3
4use crate::core::executor::ModuleExecutor;
5use crate::core::governance::{ApprovalQueue, PolicyPackStore, Role};
6use crate::core::job::JobManager;
7use crate::core::session::SessionManager;
8
9pub struct Framework {
10    pub executor: ModuleExecutor,
11    pub sessions: SessionManager,
12    pub jobs: JobManager,
13    pub operator_role: Role,
14    pub policy_packs: PolicyPackStore,
15    pub approval_queue: ApprovalQueue,
16    #[allow(clippy::type_complexity)]
17    pub proxies: std::collections::HashMap<
18        u16,
19        (
20            String,
21            Box<dyn crate::core::proxy::NetworkIsolator>,
22            tokio::task::JoinHandle<()>,
23        ),
24    >,
25}
26
27impl Framework {
28    pub fn new(executor: ModuleExecutor) -> Self {
29        Framework {
30            executor,
31            sessions: SessionManager::new(),
32            jobs: JobManager::new(),
33            operator_role: Role::Admin,
34            policy_packs: PolicyPackStore::new(),
35            approval_queue: ApprovalQueue::default(),
36            proxies: std::collections::HashMap::new(),
37        }
38    }
39}
40
41pub type SharedFramework = Arc<Mutex<Framework>>;
42
43pub fn new_shared_framework(executor: ModuleExecutor) -> SharedFramework {
44    Arc::new(Mutex::new(Framework::new(executor)))
45}