refactor#1

pull/3/head
prplV 2025-01-21 16:03:16 +03:00
parent 1f5656f7b8
commit ab75252e6b
3 changed files with 9 additions and 7 deletions

View File

@ -21,6 +21,7 @@ async fn main() -> Result<()>{
// config update channel
let (tx, mut rx) = mpsc::channel::<ApiConfig>(1);
// futures
// todo : rewrite with spawn
let config_fut = init_config_grub_mechanism(&tx);
let grub_fut = init_api_grub_mechanism(config, &mut rx);

View File

@ -3,7 +3,7 @@
use anyhow::{Error, Result};
use integr_structs::api::ApiConfig;
use tokio::time::{sleep, Instant};
use tokio::time::{sleep, Duration};
use tokio::net::UnixStream;
use std::env;
use tokio::sync::mpsc::Receiver;
@ -31,15 +31,16 @@ pub async fn init_delivery_mech(rx: ConfigGateway) -> Result<()> {
match UnixSocketConsumer::ApiGrubber.get_stream_object().await {
Ok(socket) => {
socket.try_write(to_string_pretty(&config)?.as_bytes())?;
info!("New api config was pulled");
},
Err(er) => {
error!("Cannot coonect to ApiGrubber Unix-Socket due to {er}");
}
}
sleep(Duration::from_secs(3)).await;
}
// let api_sock = UnixSocketConsumer::ApiGrubber.get_stream_object().await?;
// let preproc_sock = UnixSocketConsumer::Preproc.get_stream_object().await?;
Ok(())
}
impl UnixSocketConsumer {
@ -52,12 +53,13 @@ impl UnixSocketConsumer {
}
}
async fn check_unix_socket_file(path: &str) -> bool {
std::path::Path::new(path).exists()
}
// async fn check_unix_socket_file(path: &str) -> bool {
// std::path::Path::new(path).exists()
// }
#[cfg(tests)]
#[cfg(test)]
mod delivery_unittests {
#[allow(unused_imports)]
use super::*;
use tokio::test;

View File

@ -10,7 +10,6 @@ use tokio::sync::mpsc;
use log::{info, error};
use integration::init_integration_mech;
use delivery::init_delivery_mech;
use tokio::task::JoinHandle;
use std::sync::Arc;
// Arch :