tt_framework/
master.rs

1//!
2//! # Resource Master
3//!
4//! This module act as the global controller, all resoures are under its management.
5//!
6
7use crate::model::{Env, EnvId, Vm, VmId};
8use lazy_static::lazy_static;
9use parking_lot::RwLock;
10use std::{
11    collections::{HashMap, HashSet},
12    sync::Arc,
13};
14
15lazy_static! {
16    /// Global entrypoint of the **TT** service.
17    pub static ref SERV: Arc<Service> = Arc::new(Service::default());
18}
19
20/// Alias of client ID.
21pub type UserId = String;
22
23/// Service is a global data collection.
24#[derive(Default)]
25pub struct Service {
26    #[allow(missing_docs)]
27    pub user_to_env: Arc<RwLock<HashMap<UserId, HashSet<EnvId>>>>,
28    #[allow(missing_docs)]
29    pub all_env: Arc<RwLock<HashMap<EnvId, Env>>>,
30    #[allow(missing_docs)]
31    pub all_vm: Arc<RwLock<HashMap<VmId, Vm>>>,
32}