G: F2 reflect peer status schemas from JsonSchema derives
This commit is contained in:
1 parent
1506af11fc
commit
d2917b2483
3 files changed
+155
-184
No files matched your search
+16
-5
@@ -16,7 +16,8 @@ pub const MAX_PEERS: usize = 64;
|
||||
///
|
||||
/// Names end up in URLs, MCP arguments and metric attributes, so the
|
||||
/// character set is deliberately narrow.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, schemars::JsonSchema)]
|
||||
#[schemars(transparent)]
|
||||
pub struct PeerName(String);
|
||||
|
||||
impl PeerName {
|
||||
@@ -160,39 +161,49 @@ impl Default for PeersConfig {
|
||||
}
|
||||
|
||||
/// Registry snapshot entry, serialized as-is by REST and MCP.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, schemars::JsonSchema)]
|
||||
pub struct PeerStatus {
|
||||
/// Configured peer name.
|
||||
pub name: PeerName,
|
||||
/// `false` for a peer kept in configuration but not checked.
|
||||
pub enabled: bool,
|
||||
/// Display form of the configured URL; never carries credentials.
|
||||
pub url: String,
|
||||
/// "Server up": a TCP connect to the peer's host and port.
|
||||
pub server: ServerStatus,
|
||||
/// "API running": an authenticated `GET /api/v1/ping`.
|
||||
pub api: ApiStatus,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, schemars::JsonSchema)]
|
||||
pub struct ServerStatus {
|
||||
pub up: bool,
|
||||
/// Last change; `None` until the first check and reset on restart.
|
||||
pub since: Option<Timestamp>,
|
||||
pub last_checked: Option<Timestamp>,
|
||||
/// Failure class such as `timeout` or `unreachable`; never a URL or a secret.
|
||||
pub last_error: Option<String>,
|
||||
pub latency_ms: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, schemars::JsonSchema)]
|
||||
pub struct ApiStatus {
|
||||
pub up: bool,
|
||||
/// Last change; `None` until the first check and reset on restart.
|
||||
pub since: Option<Timestamp>,
|
||||
pub last_checked: Option<Timestamp>,
|
||||
/// Failure class such as `http_500` or `token_file`; never a URL or a secret.
|
||||
pub last_error: Option<String>,
|
||||
pub latency_ms: Option<u64>,
|
||||
/// State of the consolidator's credential on the peer.
|
||||
pub auth: AuthState,
|
||||
/// Version the peer reported, when it has the ping route.
|
||||
pub peer_version: Option<String>,
|
||||
}
|
||||
|
||||
/// `Ok` and `Rejected` refer to our credential; `Unknown` is used before the
|
||||
/// first check and for peers without the authenticated ping endpoint.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, schemars::JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum AuthState {
|
||||
Ok,
|
||||
|
||||
Reference in new issue
Block a user