Compare commits

...

2 Commits

Author SHA1 Message Date
prplV ab75252e6b refactor#1 2025-01-21 16:03:16 +03:00
prplV 1f5656f7b8 config template added to the repo 2025-01-21 16:02:40 +03:00
4 changed files with 30 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 :

View File

@ -0,0 +1,21 @@
{
"id" : 1 ,
"template" :
[{
"id" :"conference",
"name" : "Conference",
"url" : "https://$ip_address/api/v1/conferences",
"measure" :
[
"total", "number", "description",
"shutdown", "startTime", "stopTime",
"participants_total", "participants_online"
]
}],
"ip_address" : "127.0.0.1:8081",
"login" : "",
"pass" : "" ,
"api_key" : "908c709827bd40n98r7209837x98273",
"period" : "10",
"timeout" : "2"
}