Skip to content

Commit 885534d

Browse files
committed
feat: add runners to pb protocol
1 parent b2e5f8f commit 885534d

Some content is hidden

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

83 files changed

+5232
-4830
lines changed

Cargo.toml

Lines changed: 4 additions & 7 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
@@ -131,14 +131,13 @@ services:
131131
restart: unless-stopped
132132
command: /usr/bin/rivet-guard
133133
environment:
134-
- RUST_LOG=debug
134+
# - RUST_LOG=debug
135135
- RUST_BACKTRACE=1
136136
- RUST_LOG_ANSI_COLOR=1
137137
- RIVET_OTEL_ENABLED=1
138138
- RIVET_OTEL_SAMPLER_RATIO=1
139139
- RIVET_SERVICE_NAME=rivet-guard
140140
- RIVET_OTEL_ENDPOINT=http://otel-collector:4317
141-
# - RUST_LOG=debug,hyper=info
142141
stop_grace_period: 0s
143142
ports:
144143
# HTTP

docker/dev-full/rivet-client/config.jsonc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"client": {
33
"runner": {
4-
"flavor": "isolate",
54
// Enables running in non-privileged Docker containers
65
"use_mounts": false
76
},

docker/universal/Dockerfile

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ RUN \
4747
--mount=type=cache,target=/root/.cache,id=universal-user-cache \
4848
--mount=type=cache,target=/root/.npm,id=universal-user-npm \
4949
--mount=type=cache,target=/root/.yarn,id=universal-user-yarn \
50-
RUSTFLAGS="--cfg tokio_unstable" RIVET_BUILD_HUB=0 cargo build --bin rivet-server --bin rivet-edge-server --bin rivet-guard --bin rivet-client --bin rivet-isolate-v8-runner --bin rivet-container-runner && \
50+
RUSTFLAGS="--cfg tokio_unstable" RIVET_BUILD_HUB=0 cargo build --bin rivet-server --bin rivet-edge-server --bin rivet-guard --bin rivet-client --bin rivet-container-runner && \
5151
# cargo install --locked tokio-console && \
5252
mkdir /app/dist/ && \
53-
cp target/debug/rivet-server target/debug/rivet-edge-server target/debug/rivet-guard target/debug/rivet-client target/debug/rivet-isolate-v8-runner target/debug/rivet-container-runner /app/dist/
53+
cp target/debug/rivet-server target/debug/rivet-edge-server target/debug/rivet-guard target/debug/rivet-client target/debug/rivet-container-runner /app/dist/
5454

5555
# MARK: Server (full, base)
5656
FROM debian:12.9-slim AS server-full-base
@@ -122,19 +122,9 @@ RUN apt-get update -y && \
122122

123123
# MARK: Runner (Full)
124124
FROM --platform=linux/amd64 base-runner AS client-full
125-
COPY --from=builder /app/dist/rivet-client /app/dist/rivet-isolate-v8-runner /app/dist/rivet-container-runner /usr/local/bin/
125+
COPY --from=builder /app/dist/rivet-client /app/dist/rivet-container-runner /usr/local/bin/
126126
ENTRYPOINT ["/usr/bin/tini", "--", "rivet-client"]
127127

128-
# MARK: Runner (Isolate V8)
129-
FROM --platform=linux/amd64 base-runner AS isolate-v8-runner
130-
COPY --from=builder /app/dist/rivet-isolate-v8-runner /usr/local/bin/
131-
ENTRYPOINT ["rivet-client"]
132-
133-
# MARK: Runner (Container)
134-
FROM --platform=linux/amd64 base-runner AS container-runner
135-
COPY --from=builder /app/dist/rivet-container-runner /usr/local/bin/
136-
ENTRYPOINT ["rivet-client"]
137-
138128
# MARK: Monlith
139129
FROM --platform=linux/amd64 debian:12.9-slim AS monolith
140130
ENV DEBIAN_FRONTEND=noninteractive
@@ -175,7 +165,7 @@ COPY ./docker/monolith/rivet-client /etc/rivet-client
175165

176166
# === Copy Build Artifacts ===
177167
COPY --from=builder /app/dist/rivet-server /usr/local/bin/
178-
COPY --from=builder /app/dist/rivet-client /app/dist/rivet-isolate-v8-runner /app/dist/rivet-container-runner /usr/local/bin/
168+
COPY --from=builder /app/dist/rivet-client /app/dist/rivet-container-runner /usr/local/bin/
179169

180170
VOLUME ["/data"]
181171

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/hub-embed/build.rs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
use std::{env, fs, path::Path, path::PathBuf, process::Command};
22

33
fn main() -> Result<(), Box<dyn std::error::Error>> {
4-
// Check if yarn is installed
5-
let yarn_check = Command::new("yarn").arg("--version").status();
6-
assert!(
7-
yarn_check.is_ok() && yarn_check.unwrap().success(),
8-
"yarn is not installed, please install yarn to build this project"
9-
);
10-
114
// Get the output directory from the cargo environment variable
125
let target_dir = env::var("OUT_DIR")?;
136
let manifest_dir = env::var("CARGO_MANIFEST_DIR")?;
@@ -18,10 +11,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
1811
fs::remove_dir_all(out_dir)?;
1912
}
2013

14+
let project_root = PathBuf::from(manifest_dir.clone()).join("../../..");
15+
let hub_path = project_root.join("frontend/apps/hub");
16+
17+
// Build hub
2118
if std::env::var("RIVET_BUILD_HUB").map_or(false, |x| x == "1") {
22-
// Build hub
23-
let project_root = PathBuf::from(manifest_dir.clone()).join("../../..");
24-
let hub_path = project_root.join("frontend/apps/hub");
19+
// Check if yarn is installed
20+
let yarn_check = Command::new("yarn").arg("--version").status();
21+
assert!(
22+
yarn_check.is_ok() && yarn_check.unwrap().success(),
23+
"yarn is not installed, please install yarn to build this project"
24+
);
2525

2626
println!("Running yarn install");
2727
let output = Command::new("yarn")
@@ -42,21 +42,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4242
println!("stdout:\n{}", String::from_utf8_lossy(&output.stdout));
4343
println!("stderr:\n{}", String::from_utf8_lossy(&output.stderr));
4444
assert!(output.status.success(), "hub build failed");
45-
46-
// Copy dist directory to out_dir
47-
let dist_path = hub_path.join("dist");
48-
fs_extra::dir::copy(
49-
dist_path.clone(),
50-
out_dir,
51-
&fs_extra::dir::CopyOptions::new().content_only(true),
52-
)?;
53-
54-
println!("cargo:rerun-if-changed={}", hub_path.display());
55-
println!("cargo:rerun-if-env-changed=FONTAWESOME_PACKAGE_TOKEN");
56-
} else {
57-
// Create empty dist dir
58-
std::fs::create_dir_all(out_dir)?;
5945
}
46+
47+
// Copy dist directory to out_dir
48+
let dist_path = hub_path.join("dist");
49+
fs_extra::dir::copy(
50+
dist_path.clone(),
51+
out_dir,
52+
&fs_extra::dir::CopyOptions::new().content_only(true),
53+
)?;
54+
55+
println!("cargo:rerun-if-changed={}", hub_path.display());
56+
println!("cargo:rerun-if-env-changed=FONTAWESOME_PACKAGE_TOKEN");
6057

6158
// Set the path in the env
6259
println!("cargo:rustc-env=HUB_PATH={}", out_dir.display());

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.

0 commit comments

Comments
 (0)