Compare commits
3 Commits
9560157035
...
60d325e4bf
| Author | SHA1 | Date |
|---|---|---|
|
|
60d325e4bf | |
|
|
aca94a9ad2 | |
|
|
9a70171a5e |
|
|
@ -1,2 +1,3 @@
|
||||||
/target
|
/target
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
|
*.sock
|
||||||
|
|
@ -1,15 +1,11 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = [
|
members = [
|
||||||
"crates/api-puller",
|
"crates/api-grub", "crates/config-delivery", "crates/integr-structs", "crates/preproc",
|
||||||
"crates/snmp-puller",
|
|
||||||
"crates/integr-config",
|
|
||||||
"crates/data-transfer",
|
|
||||||
"crates/integrd",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
debug = true
|
debug = true
|
||||||
|
|
||||||
[profile.test]
|
[profile.test]
|
||||||
debug = false
|
debug = false
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
[package]
|
||||||
|
name = "api-grub"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { version = "1.0.217", features = ["derive"] }
|
||||||
|
serde_json = "1.0.135"
|
||||||
|
tokio = { version = "1.43.0", features = ["full"] }
|
||||||
|
integr-structs = {path = "../integr-structs"}
|
||||||
|
env_logger = "0.11.6"
|
||||||
|
log = "0.4.25"
|
||||||
|
anyhow = "1.0.95"
|
||||||
|
chrono = "0.4.39"
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"api-endpoint" : "http://127.0.0.1:8081/ping",
|
||||||
|
"method" : "GET",
|
||||||
|
"delay" : "5"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
// mod to communicate with api-grub config file
|
||||||
|
// 1) check changes in unix-socket
|
||||||
|
// 2) save changes in local config file
|
||||||
|
use integr_structs::api::ApiConfig;
|
||||||
|
use tokio::net::UnixListener;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
// for config pulling
|
||||||
|
async fn init_api_grub_mechanism(config: ApiConfig) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async fn init_unix_listener() {}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
use chrono::Local;
|
||||||
|
use env_logger::Builder;
|
||||||
|
use log::LevelFilter;
|
||||||
|
use std::io::Write;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
pub fn setup_logger() -> Result<()> {
|
||||||
|
Builder::new()
|
||||||
|
.format(move |buf, record| {
|
||||||
|
writeln!(
|
||||||
|
buf,
|
||||||
|
"|{}| {} [{}] - {}",
|
||||||
|
"api-grubber",
|
||||||
|
Local::now().format("%d-%m-%Y %H:%M:%S"),
|
||||||
|
record.level(),
|
||||||
|
record.args(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.filter(None, LevelFilter::Info)
|
||||||
|
.target(env_logger::Target::Stdout)
|
||||||
|
.init();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
mod config;
|
||||||
|
mod net;
|
||||||
|
mod logger;
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
use logger::setup_logger;
|
||||||
|
use log::info;
|
||||||
|
|
||||||
|
#[tokio::main(flavor = "multi_thread")]
|
||||||
|
async fn main() -> Result<()>{
|
||||||
|
// 3 coroutines
|
||||||
|
// 1) unix-socket coroutine (for config updating)
|
||||||
|
// 2) api coroutine
|
||||||
|
// 3) ?
|
||||||
|
setup_logger()?;
|
||||||
|
info!("Logger configured");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
// module to handle unix-socket connection + pulling info from api
|
||||||
|
use anyhow;
|
||||||
|
|
||||||
|
|
||||||
|
// for api info pulling
|
||||||
|
async fn init_api_grub_mechanism() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "api-puller"
|
name = "config-delivery"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "data-transfer"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "integr-config"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "integr-structs"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { version = "1.0.217", features = ["derive"] }
|
||||||
|
serde_json = "1.0.135"
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct ApiConfig {
|
||||||
|
url : String,
|
||||||
|
method : String,
|
||||||
|
delay : u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl Default for ApiConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
ApiConfig {
|
||||||
|
url : String::new(),
|
||||||
|
method : String::new(),
|
||||||
|
delay : 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
pub mod api;
|
||||||
|
pub mod preproc;
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "integrd"
|
name = "preproc"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "snmp-puller"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue