Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/infra/engine/src/run_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub fn config(_rivet_config: rivet_config::Config) -> Result<RunConfigData> {
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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::<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 {}

Expand Down
Loading