Skip to content

Commit 7a40790

Browse files
committed
feat: add runners to pb protocol
1 parent fbd6691 commit 7a40790

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+5123
-4484
lines changed

Cargo.toml

Lines changed: 1 addition & 4 deletions
Large diffs are not rendered by default.

docker/dev-full/docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,13 @@ services:
133133
restart: unless-stopped
134134
command: /usr/bin/rivet-guard
135135
environment:
136-
- RUST_LOG=debug
136+
# - RUST_LOG=debug
137137
- RUST_BACKTRACE=1
138138
- RUST_LOG_ANSI_COLOR=1
139139
- RIVET_OTEL_ENABLED=1
140140
- RIVET_OTEL_SAMPLER_RATIO=1
141141
- RIVET_SERVICE_NAME=rivet-guard
142142
- RIVET_OTEL_ENDPOINT=http://otel-collector:4317
143-
- RUST_LOG=debug,hyper=info
144143
stop_grace_period: 0s
145144
ports:
146145
# HTTP

examples/system-test-actor/tests/client.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ async function run() {
4949
guard: {},
5050
},
5151
},
52+
http2: {
53+
protocol: "http",
54+
internalPort: 8085,
55+
routing: {
56+
guard: {},
57+
},
58+
},
5259
udp: {
5360
protocol: "udp",
5461
// internalPort: 80,

packages/common/fdb-util/src/keys.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ pub const SQLITE: usize = 44;
4646
pub const INTERNAL: usize = 45;
4747
pub const METADATA: usize = 46;
4848
pub const COMPRESSED_DATA: usize = 47;
49+
pub const RUNNER: usize = 48;
50+
pub const RUNNERS_BY_REMAINING_SLOTS: usize = 49;
51+
pub const REMAINING_SLOTS: usize = 50;
52+
pub const TOTAL_SLOTS: usize = 51;
53+
pub const IMAGE_ID: usize = 52;
4954

5055
// Directories with fdbrs must use string paths instead of tuples
5156
pub mod dir {
@@ -103,6 +108,12 @@ pub fn key_from_str(key: &str) -> Option<usize> {
103108
"sqlite" => Some(SQLITE),
104109
"internal" => Some(INTERNAL),
105110
"metadata" => Some(METADATA),
111+
"compressed_data" => Some(COMPRESSED_DATA),
112+
"runner" => Some(RUNNER),
113+
"runners_by_remaining_slots" => Some(RUNNERS_BY_REMAINING_SLOTS),
114+
"remaining_slots" => Some(REMAINING_SLOTS),
115+
"total_slots" => Some(TOTAL_SLOTS),
116+
"image_id" => Some(IMAGE_ID),
106117
_ => None,
107118
}
108119
}

packages/common/util/core/src/serde.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{
33
fmt,
44
hash::{Hash, Hasher},
55
marker::PhantomData,
6-
ops::Deref,
6+
ops::{Deref, DerefMut},
77
};
88

99
use indexmap::IndexMap;
@@ -125,6 +125,10 @@ impl<K: Eq + Hash, V: Hash> HashableMap<K, V> {
125125
pub fn new() -> Self {
126126
HashableMap(IndexMap::new())
127127
}
128+
129+
pub fn with_capacity(capacity: usize) -> Self {
130+
HashableMap(IndexMap::with_capacity(capacity))
131+
}
128132
}
129133

130134
impl<K: Eq + Hash, V: Hash> Default for HashableMap<K, V> {
@@ -141,6 +145,12 @@ impl<K: Eq + Hash, V: Hash> Deref for HashableMap<K, V> {
141145
}
142146
}
143147

148+
impl<K: Eq + Hash, V: Hash> DerefMut for HashableMap<K, V> {
149+
fn deref_mut(&mut self) -> &mut Self::Target {
150+
&mut self.0
151+
}
152+
}
153+
144154
impl<K: Eq + Ord + Hash, V: Hash> Hash for HashableMap<K, V> {
145155
fn hash<H: Hasher>(&self, state: &mut H) {
146156
let mut kv = Vec::from_iter(&self.0);

packages/core/api/actor/src/route/builds.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ pub async fn create_build(
361361
.compression
362362
.map(ApiInto::api_into)
363363
.unwrap_or(build::types::BuildCompression::None),
364+
allocation_type: build::types::BuildAllocationType::Single,
365+
allocation_total_slots: 1,
364366
})
365367
.await?;
366368

packages/core/services/build/db/build/migrations/20250508204859_alloc_type.down.sql

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE builds
2+
ADD allocation_type INT NOT NULL DEFAULT 0,
3+
ADD allocation_total_slots INT NOT NULL DEFAULT 1;

packages/core/services/build/src/ops/create.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rivet_operation::prelude::proto::backend;
44
const MAX_UPLOAD_SIZE: u64 = util::file_size::gigabytes(8);
55
const MAX_JS_BUILD_UPLOAD_SIZE: u64 = util::file_size::megabytes(10);
66
use crate::{
7-
types::{upload::PrepareFile, upload::PresignedUploadRequest, BuildCompression, BuildKind},
7+
types::{upload::PrepareFile, upload::PresignedUploadRequest, BuildCompression, BuildAllocationType, BuildKind},
88
utils,
99
};
1010

@@ -15,6 +15,8 @@ pub struct Input {
1515
pub content: Content,
1616
pub kind: BuildKind,
1717
pub compression: BuildCompression,
18+
pub allocation_type: BuildAllocationType,
19+
pub allocation_total_slots: u64,
1820
}
1921

2022
#[derive(Debug)]
@@ -158,10 +160,12 @@ pub async fn get(ctx: &OperationCtx, input: &Input) -> GlobalResult<Output> {
158160
image_tag,
159161
create_ts,
160162
kind,
161-
compression
163+
compression,
164+
allocation_type,
165+
allocation_total_slots
162166
)
163167
VALUES
164-
($1, $2, $3, $4, $5, $6, $7, $8, $9)
168+
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
165169
",
166170
build_id,
167171
game_id,
@@ -172,6 +176,8 @@ pub async fn get(ctx: &OperationCtx, input: &Input) -> GlobalResult<Output> {
172176
ctx.ts(),
173177
input.kind as i32,
174178
input.compression as i32,
179+
input.allocation_type as i32,
180+
input.allocation_total_slots as i64,
175181
)
176182
.await?;
177183

packages/core/services/build/src/ops/get.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub(crate) struct BuildRow {
2424
create_ts: i64,
2525
kind: i64,
2626
compression: i64,
27+
allocation_type: i64,
28+
allocation_total_slots: i64,
2729
tags: sqlx::types::Json<Box<serde_json::value::RawValue>>,
2830
}
2931

@@ -43,6 +45,10 @@ impl TryInto<types::Build> for BuildRow {
4345
compression: unwrap!(types::BuildCompression::from_repr(
4446
self.compression.try_into()?
4547
)),
48+
allocation_type: unwrap!(types::BuildAllocationType::from_repr(
49+
self.allocation_type.try_into()?
50+
)),
51+
allocation_total_slots: self.allocation_total_slots.try_into()?,
4652
// Filter out null values on tags
4753
tags: serde_json::from_str::<HashMap<String, Option<String>>>(self.tags.0.get())?
4854
.into_iter()
@@ -74,6 +80,8 @@ pub async fn build_get(ctx: &OperationCtx, input: &Input) -> GlobalResult<Output
7480
create_ts,
7581
kind,
7682
compression,
83+
allocation_type,
84+
allocation_total_slots,
7785
tags
7886
FROM db_build.builds
7987
WHERE build_id = ANY($1)

0 commit comments

Comments
 (0)