Skip to content

Commit 7ad1830

Browse files
committed
chore(pegboard): migrate pegboard-ws to custom serve
1 parent 26ffb46 commit 7ad1830

File tree

13 files changed

+716
-746
lines changed

13 files changed

+716
-746
lines changed

Cargo.lock

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

out/openapi.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/common/config/src/config/mod.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub mod clickhouse;
1010
pub mod db;
1111
pub mod guard;
1212
pub mod logs;
13-
pub mod pegboard;
1413
pub mod pegboard_gateway;
1514
pub mod pegboard_tunnel;
1615
pub mod pubsub;
@@ -25,7 +24,6 @@ pub use clickhouse::*;
2524
pub use db::Database;
2625
pub use guard::*;
2726
pub use logs::*;
28-
pub use pegboard::*;
2927
pub use pegboard_gateway::*;
3028
pub use pegboard_tunnel::*;
3129
pub use pubsub::PubSub;
@@ -73,9 +71,6 @@ pub struct Root {
7371
#[serde(default)]
7472
pub api_peer: Option<ApiPeer>,
7573

76-
#[serde(default)]
77-
pub pegboard: Option<Pegboard>,
78-
7974
#[serde(default)]
8075
pub pegboard_gateway: Option<PegboardGateway>,
8176

@@ -113,7 +108,6 @@ impl Default for Root {
113108
guard: None,
114109
api_public: None,
115110
api_peer: None,
116-
pegboard: None,
117111
pegboard_gateway: None,
118112
pegboard_tunnel: None,
119113
logs: None,
@@ -144,11 +138,6 @@ impl Root {
144138
self.api_peer.as_ref().unwrap_or(&DEFAULT)
145139
}
146140

147-
pub fn pegboard(&self) -> &Pegboard {
148-
static DEFAULT: LazyLock<Pegboard> = LazyLock::new(Pegboard::default);
149-
self.pegboard.as_ref().unwrap_or(&DEFAULT)
150-
}
151-
152141
pub fn pegboard_gateway(&self) -> &PegboardGateway {
153142
static DEFAULT: LazyLock<PegboardGateway> = LazyLock::new(PegboardGateway::default);
154143
self.pegboard_gateway.as_ref().unwrap_or(&DEFAULT)

packages/common/config/src/config/pegboard.rs

Lines changed: 0 additions & 34 deletions
This file was deleted.

packages/common/test-deps/src/datacenter.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,10 @@ pub async fn setup_single_datacenter(
6060
dc = dc.datacenter_label,
6161
"containers started, waiting for services to be ready"
6262
);
63-
// Pick ports for other services
64-
let pegboard_port = portpicker::pick_unused_port().context("pegboard_port")?;
6563

6664
tracing::info!(
6765
dc = dc.datacenter_label,
6866
api_peer_port,
69-
pegboard_port,
7067
guard_port,
7168
"using ports for test services"
7269
);
@@ -80,10 +77,6 @@ pub async fn setup_single_datacenter(
8077
port: Some(api_peer_port),
8178
..Default::default()
8279
});
83-
root.pegboard = Some(rivet_config::config::Pegboard {
84-
port: Some(pegboard_port),
85-
..Default::default()
86-
});
8780

8881
root.topology = Some(rivet_config::config::topology::Topology {
8982
datacenter_label: dc.datacenter_label,
@@ -111,7 +104,6 @@ pub async fn setup_single_datacenter(
111104
container_names,
112105
api_peer_port,
113106
guard_port,
114-
pegboard_port,
115107
stop_docker_containers_on_drop: true,
116108
})
117109
}

packages/common/test-deps/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub struct TestDeps {
1313
pub config: rivet_config::Config,
1414
container_names: Vec<String>,
1515
api_peer_port: u16,
16-
pegboard_port: u16,
1716
guard_port: u16,
1817
stop_docker_containers_on_drop: bool,
1918
}
@@ -87,10 +86,6 @@ impl TestDeps {
8786
self.api_peer_port
8887
}
8988

90-
pub fn pegboard_port(&self) -> u16 {
91-
self.pegboard_port
92-
}
93-
9489
pub fn guard_port(&self) -> u16 {
9590
self.guard_port
9691
}

packages/core/guard/server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ once_cell.workspace = true
2626
pegboard-gateway.workspace = true
2727
pegboard-tunnel.workspace = true
2828
pegboard.workspace = true
29+
pegboard-runner-ws.workspace = true
2930
regex.workspace = true
3031
rivet-api-public.workspace = true
3132
rivet-cache.workspace = true
Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use anyhow::*;
22
use gas::prelude::*;
33
use rivet_guard_core::proxy_service::{RouteConfig, RouteTarget, RoutingOutput, RoutingTimeout};
4+
use std::sync::Arc;
45

56
/// Route requests to the API service
67
#[tracing::instrument(skip_all)]
@@ -10,22 +11,10 @@ pub async fn route_request(
1011
_host: &str,
1112
path: &str,
1213
) -> Result<Option<RoutingOutput>> {
13-
// Check target
1414
if target != "runner-ws" {
1515
return Ok(None);
1616
}
1717

18-
let targets = vec![RouteTarget {
19-
actor_id: None,
20-
host: ctx.config().pegboard().lan_host().to_string(),
21-
port: ctx.config().pegboard().port(),
22-
path: path.to_owned(),
23-
}];
24-
25-
return Ok(Some(RoutingOutput::Route(RouteConfig {
26-
targets,
27-
timeout: RoutingTimeout {
28-
routing_timeout: 10, // 10 seconds for API routing timeout
29-
},
30-
})));
18+
let tunnel = pegboard_runner_ws::PegboardRunnerWsCustomServe::new(ctx.clone());
19+
Ok(Some(RoutingOutput::CustomServe(Arc::new(tunnel))))
3120
}

packages/core/pegboard-runner-ws/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ edition.workspace = true
77

88
[dependencies]
99
anyhow.workspace = true
10+
async-trait.workspace = true
11+
bytes.workspace = true
12+
futures-util.workspace = true
1013
gas.workspace = true
14+
http-body.workspace = true
15+
http-body-util.workspace = true
1116
# Idk how to get this working with the workspace version
1217
hyper = "1.6"
18+
hyper-tungstenite.workspace = true
19+
hyper-util = "0.1"
1320
rivet-config.workspace = true
1421
rivet-error.workspace = true
22+
rivet-guard-core.workspace = true
1523
rivet-metrics.workspace = true
1624
rivet-runner-protocol.workspace = true
1725
rivet-runtime.workspace = true

0 commit comments

Comments
 (0)