More plumbing, client partially implemented

Working through client implementation. The broadcast recieve + send is
working now, just have to get through all the incoming message types and
state and db work now
This commit is contained in:
2026-05-17 13:45:02 -07:00
parent 42bcebb50c
commit 907c6a8fb0
7 changed files with 363 additions and 34 deletions
+33 -2
View File
@@ -15,7 +15,7 @@ use std::process::ExitCode;
use std::str::FromStr;
use std::sync::Arc;
use serde::{Deserialize,Serialize};
use tracing::{error,instrument,warn,debug};
use tracing::{error,instrument,warn,debug,Level};
use tokio::sync::{RwLock,broadcast,mpsc};
@@ -28,6 +28,11 @@ pub struct Coordinate(Vec<i64>);
#[tokio::main]
#[instrument]
async fn main() -> ExitCode {
// Initial logger so we have something during config
tracing::subscriber::set_global_default(
tracing_subscriber::fmt().with_max_level(Level::WARN).finish()
).expect("Failed to setup logger");
// Read in config
let config = match Config::load() {
Ok(c) => c,
@@ -38,6 +43,30 @@ async fn main() -> ExitCode {
}
};
let level = match config.loglevel {
Some(ref s) => {
let loglevel = s.to_lowercase();
match loglevel.as_str() {
"trace" => Level::TRACE,
"debug" => Level::DEBUG,
"info" => Level::INFO,
"warn" => Level::WARN,
"error" => Level::ERROR,
_ => {
warn!("Invalid loglevel in config: {}",&loglevel);
Level::INFO
},
}
},
// Default to info level
None => Level::INFO
};
tracing::subscriber::set_global_default(
tracing_subscriber::fmt().with_max_level(level).finish()
).expect("Failed to setup logger");
// Set up database connection
let db_config = AsyncDieselConnectionManager::<diesel_async::AsyncPgConnection>::new(config.database.url.clone());
let db_pool = match Pool::builder(db_config).build() {
@@ -146,6 +175,7 @@ async fn main() -> ExitCode {
// Create client listener
let statehandle_cloned = statehandle.clone();
let config_cloned = config.clone();
join_handles.push(tokio::spawn(async move {
connection::client_handler(
statehandle_cloned,
@@ -153,7 +183,8 @@ async fn main() -> ExitCode {
message_ack_send,
db_pool,
endpoint,
close_recv.resubscribe()
close_recv.resubscribe(),
config_cloned
).await;
} ));