Skip to content

Commit dab06b3

Browse files
committed
chore: remove port name
1 parent 6b11630 commit dab06b3

File tree

15 files changed

+110
-210
lines changed

15 files changed

+110
-210
lines changed

frontend/src/queries/actor-engine.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const createEngineActorContext = ({
1818
headers: {
1919
"x-rivet-actor": actorId,
2020
"x-rivet-target": "actor",
21-
"x-rivet-port": "main",
2221
...(token ? { authorization: `Bearer ${token}` } : {}),
2322
},
2423
};

packages/core/guard/server/src/cache/actor.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
use anyhow::Result;
77
use gas::prelude::*;
88

9-
use crate::routing::pegboard_gateway::{X_RIVET_ACTOR, X_RIVET_PORT};
9+
use crate::routing::pegboard_gateway::X_RIVET_ACTOR;
1010

1111
#[tracing::instrument(skip_all)]
1212
pub fn build_cache_key(target: &str, path: &str, headers: &hyper::HeaderMap) -> Result<u64> {
@@ -22,19 +22,10 @@ pub fn build_cache_key(target: &str, path: &str, headers: &hyper::HeaderMap) ->
2222
})?;
2323
let actor_id = Id::parse(actor_id_str.to_str()?)?;
2424

25-
let port_name = headers.get(X_RIVET_PORT).ok_or_else(|| {
26-
crate::errors::MissingHeader {
27-
header: X_RIVET_PORT.to_string(),
28-
}
29-
.build()
30-
})?;
31-
let port_name = port_name.to_str()?;
32-
33-
// Create a hash using target, actor_id and port_name
25+
// Create a hash using target, actor_id, and path
3426
let mut hasher = DefaultHasher::new();
3527
target.hash(&mut hasher);
3628
actor_id.hash(&mut hasher);
37-
port_name.hash(&mut hasher);
3829
path.hash(&mut hasher);
3930
let hash = hasher.finish();
4031

packages/core/guard/server/src/errors.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@ pub struct WrongAddrProtocol {
4343
"guard",
4444
"actor_not_found",
4545
"Actor not found.",
46-
"Actor with ID {actor_id} and port {port_name} not found."
46+
"Actor with ID {actor_id} not found."
4747
)]
4848
pub struct ActorNotFound {
4949
pub actor_id: Id,
50-
pub port_name: String,
5150
}
5251

5352
#[derive(RivetError, Serialize)]

packages/core/guard/server/src/routing/pegboard_gateway.rs

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crate::errors;
1010

1111
const ACTOR_READY_TIMEOUT: Duration = Duration::from_secs(10);
1212
pub const X_RIVET_ACTOR: HeaderName = HeaderName::from_static("x-rivet-actor");
13-
pub const X_RIVET_PORT: HeaderName = HeaderName::from_static("x-rivet-port");
1413

1514
/// Route requests to actor services based on hostname and path
1615
#[tracing::instrument(skip_all)]
@@ -64,16 +63,8 @@ pub async fn route_request(
6463
})));
6564
}
6665

67-
let port_name = headers.get(X_RIVET_PORT).ok_or_else(|| {
68-
crate::errors::MissingHeader {
69-
header: X_RIVET_PORT.to_string(),
70-
}
71-
.build()
72-
})?;
73-
let port_name = port_name.to_str()?;
74-
7566
// Lookup actor
76-
find_actor(ctx, actor_id, port_name, path).await
67+
find_actor(ctx, actor_id, path).await
7768
}
7869

7970
struct FoundActor {
@@ -82,12 +73,11 @@ struct FoundActor {
8273
destroyed: bool,
8374
}
8475

85-
/// Find an actor by actor_id and port_name
86-
#[tracing::instrument(skip_all, fields(%actor_id, %port_name, %path))]
76+
/// Find an actor by actor_id
77+
#[tracing::instrument(skip_all, fields(%actor_id, %path))]
8778
async fn find_actor(
8879
ctx: &StandaloneCtx,
8980
actor_id: Id,
90-
port_name: &str,
9181
path: &str,
9282
) -> Result<Option<RoutingOutput>> {
9383
// TODO: Optimize this down to a single FDB call
@@ -134,11 +124,7 @@ async fn find_actor(
134124
.await??;
135125

136126
let Some(actor) = actor_res else {
137-
return Err(errors::ActorNotFound {
138-
actor_id,
139-
port_name: port_name.to_string(),
140-
}
141-
.build());
127+
return Err(errors::ActorNotFound { actor_id }.build());
142128
};
143129

144130
if actor.destroyed {
@@ -186,12 +172,7 @@ async fn find_actor(
186172
tracing::debug!(?actor_id, ?runner_id, "actor ready");
187173

188174
// Return pegboard-gateway instance
189-
let gateway = pegboard_gateway::PegboardGateway::new(
190-
ctx.clone(),
191-
actor_id,
192-
runner_id,
193-
port_name.to_string(),
194-
);
175+
let gateway = pegboard_gateway::PegboardGateway::new(ctx.clone(), actor_id, runner_id);
195176
Ok(Some(RoutingOutput::CustomServe(std::sync::Arc::new(
196177
gateway,
197178
))))

packages/core/pegboard-gateway/src/lib.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,15 @@ pub struct PegboardGateway {
4444
request_counter: AtomicU64,
4545
actor_id: Id,
4646
runner_id: Id,
47-
port_name: String,
4847
}
4948

5049
impl PegboardGateway {
51-
pub fn new(ctx: StandaloneCtx, actor_id: Id, runner_id: Id, port_name: String) -> Self {
50+
pub fn new(ctx: StandaloneCtx, actor_id: Id, runner_id: Id) -> Self {
5251
Self {
5352
ctx,
5453
request_counter: AtomicU64::new(0),
5554
actor_id,
5655
runner_id,
57-
port_name,
5856
}
5957
}
6058
}
@@ -173,13 +171,12 @@ impl PegboardGateway {
173171
.map_err(|e| anyhow!("failed to serialize message: {}", e))?;
174172

175173
// Build pubsub topic
176-
let tunnel_subject = TunnelHttpRunnerSubject::new(self.runner_id, &self.port_name);
174+
let tunnel_subject = TunnelHttpRunnerSubject::new(self.runner_id);
177175
let topic = tunnel_subject.to_string();
178176

179177
tracing::info!(
180178
%topic,
181179
?self.runner_id,
182-
%self.port_name,
183180
?request_id,
184181
"publishing request to pubsub"
185182
);
@@ -190,8 +187,7 @@ impl PegboardGateway {
190187
response_map.lock().await.insert(request_id, response_tx);
191188

192189
// Subscribe to response topic
193-
let response_subject =
194-
TunnelHttpResponseSubject::new(self.runner_id, &self.port_name, request_id);
190+
let response_subject = TunnelHttpResponseSubject::new(self.runner_id, request_id);
195191
let response_topic = response_subject.to_string();
196192

197193
tracing::info!(
@@ -327,16 +323,15 @@ impl PegboardGateway {
327323

328324
// Subscribe to messages from server before informing server that a client websocket is connecting to
329325
// prevent race conditions.
330-
let ws_subject =
331-
TunnelHttpWebSocketSubject::new(self.runner_id, &self.port_name, websocket_id);
326+
let ws_subject = TunnelHttpWebSocketSubject::new(self.runner_id, websocket_id);
332327
let response_topic = ws_subject.to_string();
333328
let mut subscriber = match ups.subscribe(&response_topic).await {
334329
Result::Ok(sub) => sub,
335330
Err(err) => return Err((client_ws, err.into())),
336331
};
337332

338333
// Build pubsub topic
339-
let tunnel_subject = TunnelHttpRunnerSubject::new(self.runner_id, &self.port_name);
334+
let tunnel_subject = TunnelHttpRunnerSubject::new(self.runner_id);
340335
let topic = tunnel_subject.to_string();
341336

342337
// Send WebSocket open message

0 commit comments

Comments
 (0)