@@ -38,9 +38,9 @@ pub async fn replica_status_change(
3838}
3939
4040#[ tracing:: instrument( skip_all) ]
41- pub async fn replica_reconfigure (
42- ctx : & mut WorkflowCtx ,
43- ) -> Result < ( ) > {
41+ pub async fn replica_reconfigure ( ctx : & mut WorkflowCtx ) -> Result < ( ) > {
42+ ctx. activity ( UpdateReplicaUrlsInput { } ) . await ? ;
43+
4444 let notify_out = ctx. activity ( NotifyAllReplicasInput { } ) . await ?;
4545
4646 let replica_id = ctx. config ( ) . epoxy_replica_id ( ) ;
@@ -108,6 +108,37 @@ pub async fn increment_epoch(ctx: &ActivityCtx, _input: &IncrementEpochInput) ->
108108 Ok ( ( ) )
109109}
110110
111+ #[ derive( Debug , Clone , Serialize , Deserialize , Hash ) ]
112+ pub struct UpdateReplicaUrlsInput { }
113+
114+ #[ activity( UpdateReplicaUrls ) ]
115+ pub async fn update_replica_urls ( ctx : & ActivityCtx , _input : & UpdateReplicaUrlsInput ) -> Result < ( ) > {
116+ let mut state = ctx. state :: < State > ( ) ?;
117+
118+ // Update URLs for all replicas based on topology
119+ for replica in state. config . replicas . iter_mut ( ) {
120+ let Some ( dc) = ctx. config ( ) . dc_for_label ( replica. replica_id as u16 ) else {
121+ tracing:: warn!(
122+ replica_id = ?replica. replica_id,
123+ "datacenter not found for replica, skipping url update"
124+ ) ;
125+ continue ;
126+ } ;
127+
128+ replica. api_peer_url = dc. peer_url . to_string ( ) ;
129+ replica. guard_url = dc. public_url . to_string ( ) ;
130+
131+ tracing:: info!(
132+ replica_id = ?replica. replica_id,
133+ api_peer_url = ?dc. peer_url,
134+ guard_url = ?dc. public_url,
135+ "updated replica urls"
136+ ) ;
137+ }
138+
139+ Ok ( ( ) )
140+ }
141+
111142#[ derive( Debug , Clone , Serialize , Deserialize , Hash ) ]
112143pub struct NotifyAllReplicasInput { }
113144
0 commit comments