diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-07-14 20:53:08 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-07-14 20:53:08 +0200 |
commit | 00459f9e3d818f0fb84160862f02898d64f98110 (patch) | |
tree | d7ace4d72e8031432086026e08d37c071bd81420 /planetwars-server/src/routes/demo.rs | |
parent | 668409e76d8cc7797fe627b2e2c3d0223b3db684 (diff) | |
download | planetwars.dev-00459f9e3d818f0fb84160862f02898d64f98110.tar.xz planetwars.dev-00459f9e3d818f0fb84160862f02898d64f98110.zip |
create a configuration to hold docker registry url
Diffstat (limited to 'planetwars-server/src/routes/demo.rs')
-rw-r--r-- | planetwars-server/src/routes/demo.rs | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/planetwars-server/src/routes/demo.rs b/planetwars-server/src/routes/demo.rs index 5ff02c7..6f2d5e6 100644 --- a/planetwars-server/src/routes/demo.rs +++ b/planetwars-server/src/routes/demo.rs @@ -1,7 +1,9 @@ +use std::sync::Arc; + use crate::db; use crate::db::matches::{FullMatchData, FullMatchPlayerData}; use crate::modules::bots::save_code_string; -use crate::modules::matches::{MatchPlayer, RunMatch}; +use crate::modules::matches::{MatchPlayer, MatchRunnerConfig, RunMatch}; use crate::ConnectionPool; use axum::extract::Extension; use axum::Json; @@ -30,6 +32,7 @@ pub struct SubmitBotResponse { pub async fn submit_bot( Json(params): Json<SubmitBotParams>, Extension(pool): Extension<ConnectionPool>, + Extension(runner_config): Extension<Arc<MatchRunnerConfig>>, ) -> Result<Json<SubmitBotResponse>, StatusCode> { let conn = pool.get().await.expect("could not get database connection"); @@ -46,16 +49,19 @@ pub async fn submit_bot( // TODO: can we recover from this? .expect("could not save bot code"); - let run_match = RunMatch::from_players(vec![ - MatchPlayer::BotVersion { - bot: None, - version: player_bot_version.clone(), - }, - MatchPlayer::BotVersion { - bot: Some(opponent_bot.clone()), - version: opponent_bot_version.clone(), - }, - ]); + let run_match = RunMatch::from_players( + runner_config, + vec![ + MatchPlayer::BotVersion { + bot: None, + version: player_bot_version.clone(), + }, + MatchPlayer::BotVersion { + bot: Some(opponent_bot.clone()), + version: opponent_bot_version.clone(), + }, + ], + ); let (match_data, _) = run_match .run(pool.clone()) .await |