Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
**/.atrium
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
styled = "0.2.0"
tokio = "1.44.1"
toml = "0.8.20"
unindent = "0.2.4"
2 changes: 2 additions & 0 deletions atrium-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ version.workspace = true

[dependencies]
bytes = { workspace = true }
clap = { workspace = true }
fastrace = { workspace = true }
foyer = { workspace = true }
log = { workspace = true }
logforth = { workspace = true }
poem = { workspace = true }
serde = { workspace = true }
tokio = { workspace = true }
toml = { workspace = true }
24 changes: 24 additions & 0 deletions atrium-core/src/config.rs
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
use serde::Deserialize;
use serde::Serialize;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Config {
#[serde(default = "default_listen_addr")]
pub listen_addr: String,
#[serde(default = "default_advertise_addr")]
pub advertise_addr: String,
#[serde(default = "default_path")]
pub path: String,
pub capacity: u64,
}

fn default_listen_addr() -> String {
"0.0.0.0:7654".to_string()
}

fn default_advertise_addr() -> String {
"127.0.0.1:7654".to_string()
}

fn default_path() -> String {
"/usr/local/atrium".to_string()
}
16 changes: 16 additions & 0 deletions atrium-core/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
use clap::Parser;

use crate::config::Config;

mod config;
mod engine;
mod server;

#[derive(clap::Parser)]
struct Command {
#[clap(short, long, help = "Path to config file")]
config: String,
}

#[tokio::main]
async fn main() {
logforth::builder()
Expand All @@ -10,6 +21,11 @@ async fn main() {
})
.apply();

let cmd = Command::parse();
let config = toml::from_str::<Config>(&std::fs::read_to_string(&cmd.config).unwrap()).unwrap();

log::info!("config: {config:#?}");

let _ = server::start_server().await.inspect_err(|err| {
log::error!("server stopped: {}", err);
});
Expand Down
4 changes: 4 additions & 0 deletions dev/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
listen_addr = "127.0.0.1:7654"
advertise_addr = "127.0.0.1:7654"
path = ".atrium"
capacity = 1000000000
Loading