Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions out/openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 18 additions & 8 deletions packages/core/api-public/src/runner_configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ use crate::ctx::ApiCtx;
#[serde(deny_unknown_fields)]
#[schema(as = RunnerConfigsListResponse)]
pub struct ListResponse {
pub runner_configs: HashMap<String, HashMap<String, rivet_types::runner_configs::RunnerConfig>>,
pub runner_configs: HashMap<String, RunnerConfigDatacenters>,
pub pagination: Pagination,
}

#[derive(Deserialize, Serialize, ToSchema)]
#[schema(as = RunnerConfigsListResponseRunnerConfigsValue)]
pub struct RunnerConfigDatacenters {
pub datacenters: HashMap<String, rivet_types::runner_configs::RunnerConfig>,
}

#[utoipa::path(
get,
operation_id = "runner_configs_list",
Expand Down Expand Up @@ -64,7 +70,7 @@ async fn list_inner(
_,
_,
_,
HashMap<String, HashMap<String, rivet_types::runner_configs::RunnerConfig>>,
HashMap<String, RunnerConfigDatacenters>,
>(
ctx.clone().into(),
headers,
Expand All @@ -76,9 +82,13 @@ async fn list_inner(
},
|dc_label, res, agg| {
for (runner_name, runner_config) in res.runner_configs {
let entry = agg.entry(runner_name).or_insert_with(HashMap::new);
let entry = agg
.entry(runner_name)
.or_insert_with(|| RunnerConfigDatacenters {
datacenters: HashMap::new(),
});

entry.insert(
entry.datacenters.insert(
ctx.config()
.dc_for_label(dc_label)
.expect("dc should exist")
Expand All @@ -100,9 +110,9 @@ async fn list_inner(
#[derive(Deserialize, Serialize, ToSchema)]
#[serde(deny_unknown_fields)]
#[schema(as = RunnerConfigsUpsertRequestBody)]
pub struct UpsertRequest(
#[schema(inline)] HashMap<String, rivet_api_types::namespaces::runner_configs::RunnerConfig>,
);
pub struct UpsertRequest {
pub datacenters: HashMap<String, rivet_api_types::namespaces::runner_configs::RunnerConfig>,
}

#[utoipa::path(
put,
Expand Down Expand Up @@ -141,7 +151,7 @@ async fn upsert_inner(
ctx.auth().await?;

for dc in &ctx.config().topology().datacenters {
if let Some(runner_config) = body.0.remove(&dc.name) {
if let Some(runner_config) = body.datacenters.remove(&dc.name) {
if ctx.config().dc_label() == dc.datacenter_label {
rivet_api_peer::runner_configs::upsert(
ctx.clone().into(),
Expand Down
3 changes: 1 addition & 2 deletions packages/services/namespace/src/ops/runner_config/upsert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ pub async fn namespace_runner_config_upsert(ctx: &OperationCtx, input: &Input) -
let runner_config_key =
keys::runner_config::DataKey::new(input.namespace_id, input.name.clone());

// Delete previous config
// Delete previous index
if let Some(existing_config) = tx.read_opt(&runner_config_key, Serializable).await? {
tx.delete(&runner_config_key);
tx.delete(&keys::runner_config::ByVariantKey::new(
input.namespace_id,
runner_config_variant(&existing_config),
Expand Down
4 changes: 3 additions & 1 deletion scripts/api/runner-configs/upsert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ const response = await fetch(
"Content-Type": "application/json",
},
body: JSON.stringify({
[datacenter]: dcRunnerConfig,
datacenters: {
[datacenter]: dcRunnerConfig,
},
}),
},
);
Expand Down
4 changes: 0 additions & 4 deletions sdks/rust/data/src/versioned/namespace_runner_config.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading