planning +lcr

feature/configv2
prplV 2025-02-04 18:34:21 +03:00
parent 0f160f4dcd
commit f560dfebc5
1 changed files with 30 additions and 6 deletions

View File

@ -10,15 +10,21 @@ 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 std::ops::Deref;
use super::*;
pub async fn init_config_mechanism(cli_oneshot: Arc<Receiver<Processes>> /*...*/) {
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> {
@ -54,12 +60,30 @@ pub mod v2 {
None
}
pub async fn get_local_config_watcher(params: Arc<PrebootParams> /*...*/) {
//
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: Receiver<Processes>) -> Option<Processes> {
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),