Compare commits
2 Commits
a225ec690e
...
ab75252e6b
| Author | SHA1 | Date |
|---|---|---|
|
|
ab75252e6b | |
|
|
1f5656f7b8 |
|
|
@ -21,6 +21,7 @@ async fn main() -> Result<()>{
|
||||||
// config update channel
|
// config update channel
|
||||||
let (tx, mut rx) = mpsc::channel::<ApiConfig>(1);
|
let (tx, mut rx) = mpsc::channel::<ApiConfig>(1);
|
||||||
// futures
|
// futures
|
||||||
|
// todo : rewrite with spawn
|
||||||
let config_fut = init_config_grub_mechanism(&tx);
|
let config_fut = init_config_grub_mechanism(&tx);
|
||||||
let grub_fut = init_api_grub_mechanism(config, &mut rx);
|
let grub_fut = init_api_grub_mechanism(config, &mut rx);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use anyhow::{Error, Result};
|
use anyhow::{Error, Result};
|
||||||
use integr_structs::api::ApiConfig;
|
use integr_structs::api::ApiConfig;
|
||||||
use tokio::time::{sleep, Instant};
|
use tokio::time::{sleep, Duration};
|
||||||
use tokio::net::UnixStream;
|
use tokio::net::UnixStream;
|
||||||
use std::env;
|
use std::env;
|
||||||
use tokio::sync::mpsc::Receiver;
|
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 {
|
match UnixSocketConsumer::ApiGrubber.get_stream_object().await {
|
||||||
Ok(socket) => {
|
Ok(socket) => {
|
||||||
socket.try_write(to_string_pretty(&config)?.as_bytes())?;
|
socket.try_write(to_string_pretty(&config)?.as_bytes())?;
|
||||||
|
info!("New api config was pulled");
|
||||||
},
|
},
|
||||||
Err(er) => {
|
Err(er) => {
|
||||||
error!("Cannot coonect to ApiGrubber Unix-Socket due to {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 api_sock = UnixSocketConsumer::ApiGrubber.get_stream_object().await?;
|
||||||
// let preproc_sock = UnixSocketConsumer::Preproc.get_stream_object().await?;
|
// let preproc_sock = UnixSocketConsumer::Preproc.get_stream_object().await?;
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UnixSocketConsumer {
|
impl UnixSocketConsumer {
|
||||||
|
|
@ -52,12 +53,13 @@ impl UnixSocketConsumer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn check_unix_socket_file(path: &str) -> bool {
|
// async fn check_unix_socket_file(path: &str) -> bool {
|
||||||
std::path::Path::new(path).exists()
|
// std::path::Path::new(path).exists()
|
||||||
}
|
// }
|
||||||
|
|
||||||
#[cfg(tests)]
|
#[cfg(test)]
|
||||||
mod delivery_unittests {
|
mod delivery_unittests {
|
||||||
|
#[allow(unused_imports)]
|
||||||
use super::*;
|
use super::*;
|
||||||
use tokio::test;
|
use tokio::test;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ use tokio::sync::mpsc;
|
||||||
use log::{info, error};
|
use log::{info, error};
|
||||||
use integration::init_integration_mech;
|
use integration::init_integration_mech;
|
||||||
use delivery::init_delivery_mech;
|
use delivery::init_delivery_mech;
|
||||||
use tokio::task::JoinHandle;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
// Arch :
|
// Arch :
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue