chore: add conns as Arc Mutex AppDataConn in DataDBs and clean unused code

This commit is contained in:
Jesús Pérez Lorenzo 2021-09-19 23:17:46 +01:00
parent a353559890
commit 2574068505

View File

@ -4,27 +4,25 @@ use app_auth::{AuthStore};
use kloud::{defs::KloudStore, datacontext::DataContext};
use kloud::utils::load_from_module;
use std::sync::Arc;
use tokio::sync::Mutex;
use connectors::defs::{AppDataConn};
use clds::clouds::defs::{
CloudEnv,
Cloud,
};
use kloud::kloud::Kloud;
//use topographic_anatomy::TopographicAnatomy;
//use tracking_point::TrackingPoint;
#[derive(Clone,Default)]
pub struct CollsData {
pub klouds: KloudStore<Kloud>,
// pub ta: KloudStore<TopographicAnatomy>,
// pub tp: KloudStore<TrackingPoint>,
}
impl CollsData {
pub fn new(env: AppEnv,verbose: isize) -> Self {
// dbg!(&env.contexts);
let (klouds_frmt, klouds_content) = load_from_module(env.to_owned(),"klouds");
// let (ta_frmt, ta_content) = load_from_module(env.to_owned(),"ta");
// let (tp_frmt, tp_content) = load_from_module(env.to_owned(),"tp");
Self {
klouds: KloudStore::new(
Kloud::entries(&klouds_content,&klouds_frmt),
@ -32,16 +30,6 @@ impl CollsData {
DataContext::default(),
verbose
),
/*
ta: KloudStore::new(
TopographicAnatomy::entries(&ta_content,&ta_frmt),
"ta".to_owned(),
DataContext::default()
),
tp: KloudStore::new(
TrackingPoint::entries(&tp_content,&tp_frmt),
"tp".to_owned(), DataContext::default())
*/
}
}
pub async fn get_klouds_entries(coll_map: CollsData) -> BTreeMap<String,Kloud> {
@ -52,24 +40,6 @@ impl CollsData {
}
result
}
/*
pub async fn get_ta_entries(coll_map: CollsData) -> BTreeMap<String,TopographicAnatomy> {
let mut result = BTreeMap::new();
let cur = coll_map.ta.entries.read();
for (key,value) in cur.iter() {
result.insert(key.to_owned(), value.to_owned());
}
result
}
pub async fn get_tp_entries(coll_map: CollsData) -> BTreeMap<String,TrackingPoint> {
let mut result = BTreeMap::new();
let cur = coll_map.tp.entries.read();
for (key,value) in cur.iter() {
result.insert(key.to_owned(), value.to_owned());
}
result
}
*/
}
#[derive(Clone)]
@ -83,6 +53,7 @@ pub struct DataDBs {
pub colls: CollsData,
pub app: AppStore,
pub auth: AuthStore,
pub conns: Arc<Mutex<AppDataConn>>,
}
pub async fn load_cloud_env(cloud: &mut Cloud) {