Compare commits
No commits in common. "48d39addf04cf8a67b3bbe63f071b7c86a3ac581" and "de727de2001b3477463ff8915b9e41e84ca1bf5e" have entirely different histories.
48d39addf0
...
de727de200
3
.env
3
.env
|
|
@ -1,3 +0,0 @@
|
||||||
CONFIG_SERVER_CREDS = "ws://127.0.0.1:8080"
|
|
||||||
API_GRUBBER_SOCKET = "api-grub.sock"
|
|
||||||
PREPROC_SOCKET = "preproc.sock"
|
|
||||||
|
|
@ -10,6 +10,6 @@
|
||||||
| Crate (submodule) | Progress |
|
| Crate (submodule) | Progress |
|
||||||
|---|---|
|
|---|---|
|
||||||
|`api-grub` | ✅✅✅✅✅✅✅🔲🔲🔲 |
|
|`api-grub` | ✅✅✅✅✅✅✅🔲🔲🔲 |
|
||||||
|`config-delivery` | ✅✅✅✅🔲🔲🔲🔲🔲🔲 |
|
|`config-delivery` | 🔲🔲🔲🔲🔲🔲🔲🔲🔲🔲 |
|
||||||
|`integrs-structs` | ✅✅✅✅✅✅🔲🔲🔲🔲 |
|
|`integrs-structs` | ✅✅✅✅✅✅🔲🔲🔲🔲 |
|
||||||
|`preproc` | 🔲🔲🔲🔲🔲🔲🔲🔲🔲🔲 |
|
|`preproc` | 🔲🔲🔲🔲🔲🔲🔲🔲🔲🔲 |
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "config-delivery"
|
name = "config-delivery"
|
||||||
version = "0.3.4"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dotenv = "0.15.0"
|
|
||||||
rand = "0.8.5"
|
|
||||||
serde = { version = "1.0.217", features = ["derive"] }
|
|
||||||
serde_json = "1.0.135"
|
|
||||||
tokio = { version = "1.43.0", features = ["full"] }
|
|
||||||
tokio-websockets = { version = "^0.11.0", features = ["client", "openssl", "rand"] }
|
|
||||||
integr-structs = {path = "../integr-structs"}
|
|
||||||
anyhow = "1.0.95"
|
|
||||||
env_logger = "0.11.6"
|
|
||||||
log = "0.4.25"
|
|
||||||
chrono = "0.4.39"
|
|
||||||
|
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
// 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,50 +0,0 @@
|
||||||
use chrono::Local;
|
|
||||||
use env_logger::Builder;
|
|
||||||
use log::LevelFilter;
|
|
||||||
use std::io::Write;
|
|
||||||
use anyhow::Result;
|
|
||||||
use log::info;
|
|
||||||
|
|
||||||
pub async fn setup_logger() -> Result<()> {
|
|
||||||
Builder::new()
|
|
||||||
.format(move |buf, record| {
|
|
||||||
writeln!(
|
|
||||||
buf,
|
|
||||||
"|{}| {} [{}] - {}",
|
|
||||||
"config-delivery",
|
|
||||||
Local::now().format("%d-%m-%Y %H:%M:%S"),
|
|
||||||
record.level(),
|
|
||||||
record.args(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.filter(None, LevelFilter::Info)
|
|
||||||
.target(env_logger::Target::Stdout)
|
|
||||||
.init();
|
|
||||||
|
|
||||||
info!("Logger configured");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod logger_unittests {
|
|
||||||
use tokio::test;
|
|
||||||
use super::*;
|
|
||||||
#[test]
|
|
||||||
async fn check_logger_builder() {
|
|
||||||
Builder::new()
|
|
||||||
.format(move |buf, record| {
|
|
||||||
writeln!(
|
|
||||||
buf,
|
|
||||||
"|{}| {} [{}] - {}",
|
|
||||||
"config-delivery",
|
|
||||||
Local::now().format("%d-%m-%Y %H:%M:%S"),
|
|
||||||
record.level(),
|
|
||||||
record.args(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.filter(None, LevelFilter::Info)
|
|
||||||
.target(env_logger::Target::Stdout)
|
|
||||||
.init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +1,3 @@
|
||||||
mod delivery;
|
fn main() {
|
||||||
mod integration;
|
|
||||||
mod logger;
|
|
||||||
|
|
||||||
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