config: delivery update
parent
52cba47abe
commit
48d39addf0
|
|
@ -10,6 +10,6 @@
|
||||||
| Crate (submodule) | Progress |
|
| Crate (submodule) | Progress |
|
||||||
|---|---|
|
|---|---|
|
||||||
|`api-grub` | ✅✅✅✅✅✅✅🔲🔲🔲 |
|
|`api-grub` | ✅✅✅✅✅✅✅🔲🔲🔲 |
|
||||||
|`config-delivery` | 🔲🔲🔲🔲🔲🔲🔲🔲🔲🔲 |
|
|`config-delivery` | ✅✅✅✅🔲🔲🔲🔲🔲🔲 |
|
||||||
|`integrs-structs` | ✅✅✅✅✅✅🔲🔲🔲🔲 |
|
|`integrs-structs` | ✅✅✅✅✅✅🔲🔲🔲🔲 |
|
||||||
|`preproc` | 🔲🔲🔲🔲🔲🔲🔲🔲🔲🔲 |
|
|`preproc` | 🔲🔲🔲🔲🔲🔲🔲🔲🔲🔲 |
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
// mod to communicate with api-grub and preproc services
|
||||||
|
// using Unix-Socket Client
|
||||||
|
|
||||||
|
use anyhow::{Error, Result};
|
||||||
|
use integr_structs::api::ApiConfig;
|
||||||
|
use tokio::time::{sleep, Instant};
|
||||||
|
use tokio::net::UnixStream;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
enum UnixSocketConsumer {
|
||||||
|
ApiGrubber,
|
||||||
|
Preproc,
|
||||||
|
}
|
||||||
|
// to create us-client
|
||||||
|
struct UnixSocketClient;
|
||||||
|
|
||||||
|
impl UnixSocketConsumer {
|
||||||
|
pub async fn get_stream_object(&self) -> Result<UnixStream> {
|
||||||
|
let socket_file = match self {
|
||||||
|
UnixSocketConsumer::ApiGrubber => env::var("API_GRUBBER_SOCKET")?,
|
||||||
|
UnixSocketConsumer::Preproc => env::var("PREPROC_SOCKET")?,
|
||||||
|
};
|
||||||
|
UnixStream::connect(socket_file).await.or_else(|_| Err(Error::msg("Cannot create Unix-Socket client")))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn check_unix_socket_file(path: &str) -> bool {
|
||||||
|
std::path::Path::new(path).exists()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(tests)]
|
||||||
|
mod delivery_unittests {
|
||||||
|
use super::*;
|
||||||
|
use tokio::test;
|
||||||
|
|
||||||
|
//
|
||||||
|
#[test]
|
||||||
|
async fn check_api_unix_socket_client_creation() { assert!(true); }
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
async fn check_preproc_unix_socket_client_creation() { assert!(true); }
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,24 @@
|
||||||
mod delivery;
|
mod delivery;
|
||||||
mod integration;
|
mod integration;
|
||||||
|
mod logger;
|
||||||
|
|
||||||
fn main() {
|
use logger::setup_logger;
|
||||||
|
use dotenv::dotenv;
|
||||||
|
use anyhow::Result;
|
||||||
|
use tokio::sync::mpsc;
|
||||||
|
use log::info;
|
||||||
|
|
||||||
|
// Arch :
|
||||||
|
// 1) 2 Unix-Socket client (for api grub and preproc) :: i think its a continious process for events when services are unavailable
|
||||||
|
// 2) mpsc beetween `delivery` and `integration` ::
|
||||||
|
// 3) websocket client in `integration` to pull configs from Monitoring System ::
|
||||||
|
|
||||||
|
#[tokio::main(flavor = "multi_thread")]
|
||||||
|
async fn main() -> Result<()> {
|
||||||
|
let _ = setup_logger().await?;
|
||||||
|
dotenv().ok();
|
||||||
|
info!("Pulling env vars from .env file if exists ...");
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue