aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/modules/bot_api.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-07-14 20:53:08 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-07-14 20:53:08 +0200
commit00459f9e3d818f0fb84160862f02898d64f98110 (patch)
treed7ace4d72e8031432086026e08d37c071bd81420 /planetwars-server/src/modules/bot_api.rs
parent668409e76d8cc7797fe627b2e2c3d0223b3db684 (diff)
downloadplanetwars.dev-00459f9e3d818f0fb84160862f02898d64f98110.tar.xz
planetwars.dev-00459f9e3d818f0fb84160862f02898d64f98110.zip
create a configuration to hold docker registry url
Diffstat (limited to 'planetwars-server/src/modules/bot_api.rs')
-rw-r--r--planetwars-server/src/modules/bot_api.rs29
1 files changed, 17 insertions, 12 deletions
diff --git a/planetwars-server/src/modules/bot_api.rs b/planetwars-server/src/modules/bot_api.rs
index 0ee9357..4e7d737 100644
--- a/planetwars-server/src/modules/bot_api.rs
+++ b/planetwars-server/src/modules/bot_api.rs
@@ -21,10 +21,11 @@ use crate::db;
use crate::util::gen_alphanumeric;
use crate::ConnectionPool;
-use super::matches::{MatchPlayer, RunMatch};
+use super::matches::{MatchPlayer, MatchRunnerConfig, RunMatch};
pub struct BotApiServer {
conn_pool: ConnectionPool,
+ runner_config: Arc<MatchRunnerConfig>,
router: PlayerRouter,
}
@@ -113,15 +114,18 @@ impl pb::bot_api_service_server::BotApiService for BotApiServer {
player_key: player_key.clone(),
router: self.router.clone(),
});
- let mut run_match = RunMatch::from_players(vec![
- MatchPlayer::BotSpec {
- spec: remote_bot_spec,
- },
- MatchPlayer::BotVersion {
- bot: Some(opponent_bot),
- version: opponent_bot_version,
- },
- ]);
+ let run_match = RunMatch::from_players(
+ self.runner_config.clone(),
+ vec![
+ MatchPlayer::BotSpec {
+ spec: remote_bot_spec,
+ },
+ MatchPlayer::BotVersion {
+ bot: Some(opponent_bot),
+ version: opponent_bot_version,
+ },
+ ],
+ );
let (created_match, _) = run_match
.run(self.conn_pool.clone())
.await
@@ -261,11 +265,12 @@ async fn schedule_timeout(
.resolve_request(request_id, Err(RequestError::Timeout));
}
-pub async fn run_bot_api(pool: ConnectionPool) {
+pub async fn run_bot_api(runner_config: Arc<MatchRunnerConfig>, pool: ConnectionPool) {
let router = PlayerRouter::new();
let server = BotApiServer {
router,
- conn_pool: pool.clone(),
+ conn_pool: pool,
+ runner_config,
};
let addr = SocketAddr::from(([127, 0, 0, 1], 50051));