diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..0dca6d5 --- /dev/null +++ b/.env.example @@ -0,0 +1,7 @@ +# Template .env + +# Url to Monitoring-System (main configs distributor) web-socket +CONFIG_SERVER_CREDS = "ws://ip.ip.ip.ip:port" +# Path (full or right relative) to the API-grabber socket file +# Using internal HTTP API across Unix-Socket +API_GRUBBER_SOCKET = "api-grub.sock" \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index d6686e7..ef0dcae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,6 @@ 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" diff --git a/src/delivery.rs b/src/delivery.rs index 6226764..9a8aeb9 100644 --- a/src/delivery.rs +++ b/src/delivery.rs @@ -2,7 +2,8 @@ // using Unix-Socket Client use anyhow::{Error, Result}; -use integr_structs::api::ApiConfigV2; +// use integr_structs::api::ApiConfigV2; +use crate::structs::ApiConfigV2; use tokio::time::{sleep, Duration}; use tokio::net::UnixStream; use std::env; diff --git a/src/integration.rs b/src/integration.rs index bf883a7..39c663c 100644 --- a/src/integration.rs +++ b/src/integration.rs @@ -1,7 +1,8 @@ use std::sync::Arc; use tokio::sync::mpsc::Sender; -use integr_structs::api::ApiConfigV2; +// use integr_structs::api::ApiConfigV2; +use crate::structs::ApiConfigV2; use anyhow::Result; use tokio::time::{sleep, Duration}; // mock diff --git a/src/main.rs b/src/main.rs index e5955b7..ad90052 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,10 @@ mod delivery; mod integration; mod logger; +mod structs; -use integr_structs::api::ApiConfigV2; +// use integr_structs::api::ApiConfigV2; +use structs::ApiConfigV2; use logger::setup_logger; use dotenv::dotenv; use anyhow::Result; diff --git a/src/structs.rs b/src/structs.rs new file mode 100644 index 0000000..daf1871 --- /dev/null +++ b/src/structs.rs @@ -0,0 +1,127 @@ +use core::sync; +use std::collections::HashMap; +use serde::{Serialize, Deserialize}; +use serde_json::{ to_string_pretty, Value }; +use anyhow::Result; +use std::sync::Arc; + + +// v2 +#[derive(Serialize, Deserialize, Debug, PartialEq)] +pub struct ApiConfigV2 { + pub id : u64, + #[serde(default)] + pub template : Vec