Compare commits
3 Commits
df03bd5346
...
f560dfebc5
| Author | SHA1 | Date |
|---|---|---|
|
|
f560dfebc5 | |
|
|
0f160f4dcd | |
|
|
7a5704dd93 |
|
|
@ -10,15 +10,24 @@ use std::{env, fs};
|
||||||
use super::preboot::PrebootParams;
|
use super::preboot::PrebootParams;
|
||||||
use tokio::time::{Duration, sleep};
|
use tokio::time::{Duration, sleep};
|
||||||
// use redis::PubSub;
|
// use redis::PubSub;
|
||||||
use tokio::sync::oneshot::Receiver;
|
use tokio::sync::oneshot::Receiver as OneShotReciever;
|
||||||
|
use tokio::sync::broadcast::Sender as BroadcastSender;
|
||||||
|
|
||||||
// const CONFIG_PATH: &str = "settings.json";
|
// const CONFIG_PATH: &str = "settings.json";
|
||||||
|
|
||||||
pub mod v2 {
|
pub mod v2 {
|
||||||
use super::*;
|
use super::*;
|
||||||
pub async fn init_config_mechanism(cli_oneshot: Arc<Receiver<Processes>> /*...*/) { /* local + pubsub + cli oneshot check */ }
|
|
||||||
pub async fn get_pubsub<'a>(params: Arc<PrebootParams>) -> Option<PubSub<'a>> {
|
pub async fn init_config_mechanism(
|
||||||
// let config_path = params.config.to_str().unwrap_or_else(|| "settings.json");
|
// to handle cli config changes
|
||||||
|
_cli_oneshot: OneShotReciever<Processes>,
|
||||||
|
// to share local config with PRCS and CLI_PIPELINE modules
|
||||||
|
_brd_tx : Arc<BroadcastSender<Processes>>
|
||||||
|
/*...*/
|
||||||
|
) {
|
||||||
|
/* local + pubsub + cli oneshot check */
|
||||||
|
}
|
||||||
|
pub async fn get_redis_connection(params: Arc<PrebootParams>) -> Option<Connection> {
|
||||||
if params.no_sub {
|
if params.no_sub {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +40,7 @@ pub mod v2 {
|
||||||
// let channel_name = channel_name.trim();
|
// let channel_name = channel_name.trim();
|
||||||
let mut pubsub = conn.as_pubsub();
|
let mut pubsub = conn.as_pubsub();
|
||||||
if pubsub.subscribe(&channel_name.trim()).is_ok() {
|
if pubsub.subscribe(&channel_name.trim()).is_ok() {
|
||||||
|
|
||||||
todo!()
|
todo!()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -51,9 +60,36 @@ pub mod v2 {
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
pub async fn get_local_config_watcher(/*...*/) { /*...*/ }
|
|
||||||
//
|
//
|
||||||
pub async fn cli_config_reciever(cli_oneshot: Arc<Receiver<Processes>>) { /*...*/ }
|
pub async fn local_config_reciever(
|
||||||
|
params : Arc<PrebootParams>,
|
||||||
|
pubsub_oneshot : OneShotReciever<bool>,
|
||||||
|
brd_tx : Arc<BroadcastSender<Processes>>,
|
||||||
|
/*...*/
|
||||||
|
) {
|
||||||
|
/*...*/
|
||||||
|
|
||||||
|
// {:1} if local config is not exist -> cannot create watcher -> None
|
||||||
|
// {:2} if local config exists -> load_processes
|
||||||
|
// |
|
||||||
|
// | [Ok(Processes)]
|
||||||
|
// -> 1) broadcast sending parsed config to PRCS and CLI_PIPELINE
|
||||||
|
// 2) watcher in loop to deny local changes
|
||||||
|
// |
|
||||||
|
// | Err(_)
|
||||||
|
// ->
|
||||||
|
// ????
|
||||||
|
}
|
||||||
|
|
||||||
|
// [:IN-TEST]
|
||||||
|
pub async fn cli_config_reciever(cli_oneshot: OneShotReciever<Processes>) -> Option<Processes> {
|
||||||
|
/* match awaits til channel*/
|
||||||
|
match cli_oneshot.await {
|
||||||
|
Ok(config_from_cli) => return Some(config_from_cli),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,21 @@ pub struct Processes {
|
||||||
pub processes: Vec<TrackingProcess>,
|
pub processes: Vec<TrackingProcess>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Processes {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
date_of_creation : String::new(),
|
||||||
|
config_server : String::from("default"),
|
||||||
|
processes : Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Processes {
|
||||||
|
pub fn is_default(&self) -> bool {
|
||||||
|
self.date_of_creation.is_empty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// # Struct for the 2nd level in json conf file
|
/// # Struct for the 2nd level in json conf file
|
||||||
/// ## for each process to contain info, such as name, path and dependencies
|
/// ## for each process to contain info, such as name, path and dependencies
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue