Compare commits

...

3 Commits

Author SHA1 Message Date
prplV f560dfebc5 planning +lcr 2025-02-04 18:34:21 +03:00
prplV 0f160f4dcd deafult processes 2025-02-04 17:57:55 +03:00
prplV 7a5704dd93 cli_config_reciever fn added 2025-02-04 16:53:29 +03:00
2 changed files with 58 additions and 8 deletions

View File

@ -10,15 +10,24 @@ use std::{env, fs};
use super::preboot::PrebootParams;
use tokio::time::{Duration, sleep};
// 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";
pub mod v2 {
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>> {
// let config_path = params.config.to_str().unwrap_or_else(|| "settings.json");
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> {
if params.no_sub {
return None;
}
@ -51,9 +60,36 @@ pub mod v2 {
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,
}
}
}

View File

@ -40,7 +40,21 @@ 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