From c16b068f8b3848e775f2490851fbc788139febe0 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sun, 17 Jul 2022 15:10:17 +0200 Subject: cleanup: remove old configuration code --- planetwars-server/src/lib.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'planetwars-server') diff --git a/planetwars-server/src/lib.rs b/planetwars-server/src/lib.rs index ad7741c..123fdab 100644 --- a/planetwars-server/src/lib.rs +++ b/planetwars-server/src/lib.rs @@ -28,11 +28,9 @@ use axum::{ Router, }; -// TODO: make these configurable -const SIMPLEBOT_PATH: &str = "../simplebot/simplebot.py"; - type ConnectionPool = bb8::Pool>; +// this should probably be modularized a bit as the config grows #[derive(Serialize, Deserialize)] pub struct GlobalConfig { /// url for the postgres database @@ -59,6 +57,9 @@ pub struct GlobalConfig { pub registry_admin_password: String, } +// TODO: do we still need this? Is there a better way? +const SIMPLEBOT_PATH: &str = "../simplebot/simplebot.py"; + pub async fn seed_simplebot(config: &GlobalConfig, pool: &ConnectionPool) { let conn = pool.get().await.expect("could not get database connection"); // This transaction is expected to fail when simplebot already exists. @@ -88,7 +89,7 @@ pub type DbPool = Pool>; pub async fn prepare_db(config: &GlobalConfig) -> DbPool { let manager = DieselConnectionManager::::new(&config.database_url); let pool = bb8::Pool::builder().build(manager).await.unwrap(); - seed_simplebot(&config, &pool).await; + seed_simplebot(config, &pool).await; pool } @@ -160,11 +161,6 @@ pub async fn run_app() { axum::Server::bind(&addr).serve(api_service).await.unwrap(); } -#[derive(Deserialize)] -pub struct Configuration { - pub database_url: String, -} - // we can also write a custom extractor that grabs a connection from the pool // which setup is appropriate depends on your application pub struct DatabaseConnection(PooledConnection<'static, DieselConnectionManager>); -- cgit v1.2.3