config pubsub pre-dev skeleton
parent
e9b6abefdf
commit
df03bd5346
|
|
@ -18,18 +18,21 @@ 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 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 get_pubsub<'a>(params: Arc<PrebootParams>) -> Option<PubSub<'a>> {
|
||||||
let config_path = params.config.to_str().unwrap_or_else(|| "settings.json");
|
// let config_path = params.config.to_str().unwrap_or_else(|| "settings.json");
|
||||||
|
if params.no_sub {
|
||||||
if params.no_sub || params.no_sub {
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
let mut connection_delay: u64 = 1;
|
||||||
|
loop {
|
||||||
if let Ok(client) = Client::open(format!("redis://{}/", ¶ms.remote_server_url)) {
|
if let Ok(client) = Client::open(format!("redis://{}/", ¶ms.remote_server_url)) {
|
||||||
if let Ok(mut conn) = client.get_connection() {
|
if let Ok(mut conn) = client.get_connection() {
|
||||||
match crate::utils::get_container_id() {
|
match crate::utils::get_container_id() {
|
||||||
Some(channel_name) => {
|
Some(channel_name) => {
|
||||||
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).is_ok() {
|
if pubsub.subscribe(&channel_name.trim()).is_ok() {
|
||||||
|
|
||||||
|
todo!()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
error!("Cannot subscribe channel {}. Check Redis Server status", &channel_name);
|
error!("Cannot subscribe channel {}. Check Redis Server status", &channel_name);
|
||||||
|
|
@ -41,7 +44,11 @@ pub mod v2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error!("Error with subscribing Redis stream on update. Working only with selected config...");
|
error!("Error with subscribing Redis stream on update. Retrying in {} secs...", connection_delay);
|
||||||
|
sleep(Duration::from_secs(connection_delay)).await;
|
||||||
|
connection_delay *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
pub async fn get_local_config_watcher(/*...*/) { /*...*/ }
|
pub async fn get_local_config_watcher(/*...*/) { /*...*/ }
|
||||||
|
|
@ -360,7 +367,7 @@ fn restart_main_thread() -> std::io::Result<()> {
|
||||||
pub async fn subscribe_config_stream(actual_prcs: Arc<Processes>, params: Arc<PrebootParams>) -> Result<(), CustomError> {
|
pub async fn subscribe_config_stream(actual_prcs: Arc<Processes>, params: Arc<PrebootParams>) -> Result<(), CustomError> {
|
||||||
let config_path = params.config.to_str().unwrap_or_else(|| "settings.json");
|
let config_path = params.config.to_str().unwrap_or_else(|| "settings.json");
|
||||||
|
|
||||||
if params.no_sub || params.no_sub {
|
if params.no_sub {
|
||||||
return Err(CustomError::Fatal);
|
return Err(CustomError::Fatal);
|
||||||
}
|
}
|
||||||
if let Ok(client) = Client::open(format!("redis://{}/", ¶ms.remote_server_url)) {
|
if let Ok(client) = Client::open(format!("redis://{}/", ¶ms.remote_server_url)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue