diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-07-17 15:10:17 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-07-17 15:10:17 +0200 |
commit | c16b068f8b3848e775f2490851fbc788139febe0 (patch) | |
tree | 2523be03c127812e8bd831c89828dc86ecfe8993 | |
parent | dad19548d1e704c31800c5d6b132299ee5e88d45 (diff) | |
download | planetwars.dev-c16b068f8b3848e775f2490851fbc788139febe0.tar.xz planetwars.dev-c16b068f8b3848e775f2490851fbc788139febe0.zip |
cleanup: remove old configuration code
-rw-r--r-- | planetwars-server/src/lib.rs | 14 |
1 files changed, 5 insertions, 9 deletions
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<DieselConnectionManager<PgConnection>>; +// 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<DieselConnectionManager<PgConnection>>; pub async fn prepare_db(config: &GlobalConfig) -> DbPool { let manager = DieselConnectionManager::<PgConnection>::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<PgConnection>>); |