Skip to content

Commit a3001df

Browse files
committed
fix: make runner config props optional in api
1 parent 09fc6a5 commit a3001df

File tree

5 files changed

+55
-12
lines changed

5 files changed

+55
-12
lines changed

docker/dev/rivet-engine/config.jsonc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
"postgres": {
2525
"url": "postgresql://postgres:postgres@postgres:5432/rivet_engine"
2626
},
27-
"memory": {
28-
"channel": "default"
29-
},
3027
"cache": {
3128
"driver": "in_memory"
3229
},

out/openapi.json

Lines changed: 13 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pub mod list;
2+
pub mod runner_configs;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use std::collections::HashMap;
2+
3+
use gas::prelude::*;
4+
use utoipa::ToSchema;
5+
6+
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
7+
#[serde(rename_all = "snake_case")]
8+
pub enum RunnerConfig {
9+
Serverless {
10+
url: String,
11+
headers: Option<HashMap<String, String>>,
12+
/// Seconds.
13+
request_lifespan: u32,
14+
slots_per_runner: u32,
15+
min_runners: Option<u32>,
16+
max_runners: u32,
17+
runners_margin: Option<u32>,
18+
},
19+
}

packages/core/api-peer/src/runner_configs.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ pub struct UpsertPath {
113113
#[derive(Deserialize, Serialize, ToSchema)]
114114
#[serde(deny_unknown_fields)]
115115
#[schema(as = RunnerConfigsUpsertRequest)]
116-
pub struct UpsertRequest(#[schema(inline)] rivet_types::namespaces::RunnerConfig);
116+
pub struct UpsertRequest(
117+
#[schema(inline)] rivet_api_types::namespaces::runner_configs::RunnerConfig,
118+
);
117119

118120
#[derive(Deserialize, Serialize, ToSchema)]
119121
#[schema(as = RunnerConfigsUpsertResponse)]
@@ -135,7 +137,25 @@ pub async fn upsert(
135137
ctx.op(namespace::ops::runner_config::upsert::Input {
136138
namespace_id: namespace.namespace_id,
137139
name: path.runner_name,
138-
config: body.0,
140+
config: match body.0 {
141+
rivet_api_types::namespaces::runner_configs::RunnerConfig::Serverless {
142+
url,
143+
headers,
144+
request_lifespan,
145+
slots_per_runner,
146+
min_runners,
147+
max_runners,
148+
runners_margin,
149+
} => rivet_types::namespaces::RunnerConfig::Serverless {
150+
url,
151+
headers: headers.unwrap_or_default(),
152+
request_lifespan,
153+
slots_per_runner,
154+
min_runners: min_runners.unwrap_or_default(),
155+
max_runners,
156+
runners_margin: runners_margin.unwrap_or_default(),
157+
},
158+
},
139159
})
140160
.await?;
141161

0 commit comments

Comments
 (0)