struct changes
parent
aca94a9ad2
commit
60d325e4bf
|
|
@ -10,3 +10,5 @@ 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"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"api-endpoint" : "http://127.0.0.1:8081/ping",
|
||||
"method" : "GET"
|
||||
"method" : "GET",
|
||||
"delay" : "5"
|
||||
}
|
||||
|
|
@ -1,2 +1,14 @@
|
|||
// mod to communicate with api-grub config file
|
||||
// 1) check changes in unix-socket
|
||||
// 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(())
|
||||
}
|
||||
|
|
@ -1,5 +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() {
|
||||
println!("Hello, world!");
|
||||
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() {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue