Compare commits
No commits in common. "f560dfebc593e49a76975ae5711740fff944c68a" and "df03bd5346e919df580d6328c86a0eb5af91e043" have entirely different histories.
f560dfebc5
...
df03bd5346
|
|
@ -10,24 +10,15 @@ use std::{env, fs};
|
|||
use super::preboot::PrebootParams;
|
||||
use tokio::time::{Duration, sleep};
|
||||
// use redis::PubSub;
|
||||
use tokio::sync::oneshot::Receiver as OneShotReciever;
|
||||
use tokio::sync::broadcast::Sender as BroadcastSender;
|
||||
use tokio::sync::oneshot::Receiver;
|
||||
|
||||
// const CONFIG_PATH: &str = "settings.json";
|
||||
|
||||
pub mod v2 {
|
||||
use super::*;
|
||||
|
||||
pub async fn init_config_mechanism(
|
||||
// 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> {
|
||||
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>> {
|
||||
// let config_path = params.config.to_str().unwrap_or_else(|| "settings.json");
|
||||
if params.no_sub {
|
||||
return None;
|
||||
}
|
||||
|
|
@ -40,7 +31,7 @@ pub mod v2 {
|
|||
// let channel_name = channel_name.trim();
|
||||
let mut pubsub = conn.as_pubsub();
|
||||
if pubsub.subscribe(&channel_name.trim()).is_ok() {
|
||||
|
||||
|
||||
todo!()
|
||||
|
||||
} else {
|
||||
|
|
@ -60,36 +51,9 @@ pub mod v2 {
|
|||
|
||||
None
|
||||
}
|
||||
|
||||
//
|
||||
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,
|
||||
}
|
||||
}
|
||||
pub async fn get_local_config_watcher(/*...*/) { /*...*/ }
|
||||
//
|
||||
pub async fn cli_config_reciever(cli_oneshot: Arc<Receiver<Processes>>) { /*...*/ }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -40,21 +40,7 @@ pub struct Processes {
|
|||
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
|
||||
/// ## for each process to contain info, such as name, path and dependencies
|
||||
|
|
|
|||
Loading…
Reference in New Issue