Skip to content

Commit 6bda80f

Browse files
committed
feat(serverless): regional serverless configs
1 parent a82efeb commit 6bda80f

File tree

40 files changed

+1093
-848
lines changed

40 files changed

+1093
-848
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

out/openapi.json

Lines changed: 68 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/common/api-builder/src/extract.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use anyhow::anyhow;
21
use axum::{
32
extract::{
43
Request,

packages/common/api-types/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ pub mod actors;
22
pub mod datacenters;
33
pub mod namespaces;
44
pub mod pagination;
5+
pub mod runner_configs;
56
pub mod runners;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use std::collections::HashMap;
2+
3+
use serde::{Deserialize, Serialize};
4+
use utoipa::IntoParams;
5+
6+
use crate::pagination::Pagination;
7+
8+
#[derive(Debug, Serialize, Deserialize, Clone, IntoParams)]
9+
#[serde(deny_unknown_fields)]
10+
#[into_params(parameter_in = Query)]
11+
pub struct ListQuery {
12+
pub namespace: String,
13+
pub limit: Option<usize>,
14+
pub cursor: Option<String>,
15+
pub variant: Option<rivet_types::keys::namespace::runner_config::RunnerConfigVariant>,
16+
#[serde(default)]
17+
pub runner_names: Option<String>,
18+
}
19+
20+
#[derive(Deserialize, Clone)]
21+
#[serde(deny_unknown_fields)]
22+
pub struct ListPath {}
23+
24+
#[derive(Deserialize, Serialize)]
25+
#[serde(deny_unknown_fields)]
26+
pub struct ListResponse {
27+
pub runner_configs: HashMap<String, rivet_types::runner_configs::RunnerConfig>,
28+
pub pagination: Pagination,
29+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod list;

packages/common/api-util/src/lib.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ where
102102
Q: Serialize + Clone + Send + 'static,
103103
F: Fn(ApiCtx, Q) -> Fut + Clone + Send + 'static,
104104
Fut: Future<Output = Result<I>> + Send,
105-
A: Fn(I, &mut R),
105+
A: Fn(u16, I, &mut R),
106106
R: Default + Send + 'static,
107107
{
108108
let dcs = &ctx.config().topology().datacenters;
@@ -117,19 +117,22 @@ where
117117
async move {
118118
if dc.datacenter_label == ctx.config().dc_label() {
119119
// Local datacenter - use direct API call
120-
local_handler(ctx, query).await
120+
(dc.datacenter_label, local_handler(ctx, query).await)
121121
} else {
122122
// Remote datacenter - HTTP request
123-
request_remote_datacenter::<I>(
124-
ctx.config(),
123+
(
125124
dc.datacenter_label,
126-
&endpoint,
127-
Method::GET,
128-
headers,
129-
Some(&query),
130-
Option::<&()>::None,
125+
request_remote_datacenter::<I>(
126+
ctx.config(),
127+
dc.datacenter_label,
128+
&endpoint,
129+
Method::GET,
130+
headers,
131+
Some(&query),
132+
Option::<&()>::None,
133+
)
134+
.await,
131135
)
132-
.await
133136
}
134137
}
135138
}))
@@ -141,11 +144,11 @@ where
141144
let result_count = results.len();
142145
let mut errors = Vec::new();
143146
let mut aggregated = R::default();
144-
for res in results {
147+
for (dc_label, res) in results {
145148
match res {
146-
Ok(data) => aggregator(data, &mut aggregated),
149+
Ok(data) => aggregator(dc_label, data, &mut aggregated),
147150
Err(err) => {
148-
tracing::error!(?err, "failed to request edge dc");
151+
tracing::error!(?dc_label, ?err, "failed to request edge dc");
149152
errors.push(err);
150153
}
151154
}

packages/common/types/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ rivet-data.workspace = true
1313
rivet-runner-protocol.workspace = true
1414
rivet-util.workspace = true
1515
serde.workspace = true
16+
strum.workspace = true
1617
universaldb.workspace = true
1718
utoipa.workspace = true
1819
vbare.workspace = true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
pub mod namespace;
12
pub mod pegboard;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod runner_config;

0 commit comments

Comments
 (0)