diff --git a/packages/infra/engine/src/run_config.rs b/packages/infra/engine/src/run_config.rs index a149e9a257..6de1959538 100644 --- a/packages/infra/engine/src/run_config.rs +++ b/packages/infra/engine/src/run_config.rs @@ -6,7 +6,7 @@ pub fn config(_rivet_config: rivet_config::Config) -> Result { Service::new("api_peer", ServiceKind::ApiPeer, |config, pools| { Box::pin(rivet_api_peer::start(config, pools)) }), - Service::new("guard", ServiceKind::Standalone, |config, pools| { + Service::new("guard", ServiceKind::ApiPublic, |config, pools| { Box::pin(rivet_guard::start(config, pools)) }), Service::new( diff --git a/packages/services/epoxy/src/workflows/coordinator/replica_status_change.rs b/packages/services/epoxy/src/workflows/coordinator/replica_status_change.rs index 6d8fde554d..7445616136 100644 --- a/packages/services/epoxy/src/workflows/coordinator/replica_status_change.rs +++ b/packages/services/epoxy/src/workflows/coordinator/replica_status_change.rs @@ -38,9 +38,9 @@ pub async fn replica_status_change( } #[tracing::instrument(skip_all)] -pub async fn replica_reconfigure( - ctx: &mut WorkflowCtx, -) -> Result<()> { +pub async fn replica_reconfigure(ctx: &mut WorkflowCtx) -> Result<()> { + ctx.activity(UpdateReplicaUrlsInput {}).await?; + let notify_out = ctx.activity(NotifyAllReplicasInput {}).await?; let replica_id = ctx.config().epoxy_replica_id(); @@ -108,6 +108,37 @@ pub async fn increment_epoch(ctx: &ActivityCtx, _input: &IncrementEpochInput) -> Ok(()) } +#[derive(Debug, Clone, Serialize, Deserialize, Hash)] +pub struct UpdateReplicaUrlsInput {} + +#[activity(UpdateReplicaUrls)] +pub async fn update_replica_urls(ctx: &ActivityCtx, _input: &UpdateReplicaUrlsInput) -> Result<()> { + let mut state = ctx.state::()?; + + // Update URLs for all replicas based on topology + for replica in state.config.replicas.iter_mut() { + let Some(dc) = ctx.config().dc_for_label(replica.replica_id as u16) else { + tracing::warn!( + replica_id = ?replica.replica_id, + "datacenter not found for replica, skipping url update" + ); + continue; + }; + + replica.api_peer_url = dc.peer_url.to_string(); + replica.guard_url = dc.public_url.to_string(); + + tracing::info!( + replica_id = ?replica.replica_id, + api_peer_url = ?dc.peer_url, + guard_url = ?dc.public_url, + "updated replica urls" + ); + } + + Ok(()) +} + #[derive(Debug, Clone, Serialize, Deserialize, Hash)] pub struct NotifyAllReplicasInput {}