Skip to content

Commit 094288a

Browse files
authored
core: Make advertise_addr of Node optional (#618)
The semantics here changed slightly, in that a `None` address means that the node is known but not currently connected.
1 parent 4f74a5c commit 094288a

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

crates/client-api/src/routes/prometheus.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ pub async fn get_sd_config<S: ControlStateReadAccess>(
2222
let labels = HashMap::new();
2323

2424
for node in nodes {
25-
targets.push(node.advertise_addr);
25+
if let Some(addr) = node.advertise_addr {
26+
targets.push(addr);
27+
}
2628
}
2729

2830
let sd_config = SDConfig { targets, labels };

crates/core/src/messages/control_db.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ pub struct DatabaseInstanceStatus {
5050
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
5151
pub struct Node {
5252
pub id: u64,
53+
/// If `true`, no new user databases will be scheduled on this node.
5354
pub unschedulable: bool,
54-
/// TODO: It's unclear if this should be in here since it's arguably status
55-
/// rather than part of the configuration kind of. I dunno.
56-
pub advertise_addr: String,
55+
/// The hostname this node is reachable at.
56+
///
57+
/// If `None`, the node is not currently live.
58+
pub advertise_addr: Option<String>,
5759
}
5860
#[derive(Clone, PartialEq, Serialize, Deserialize)]
5961
pub struct NodeStatus {

crates/standalone/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl spacetimedb_client_api::ControlStateReadAccess for StandaloneEnv {
220220
return Ok(Some(Node {
221221
id: 0,
222222
unschedulable: false,
223-
advertise_addr: "node:80".into(),
223+
advertise_addr: Some("node:80".to_owned()),
224224
}));
225225
}
226226
Ok(None)

0 commit comments

Comments
 (0)