pub type NodeMetadata = Value;Expand description
Schema-less metadata for nodes.
This type alias provides maximum flexibility for arbitrary node metadata. Nodes can report any JSON-serializable data (CPU load, memory, custom metrics, etc.) and consumers (like load balancers) can interpret the metadata as needed.
§Common Metadata Keys
While the schema is flexible, these keys are commonly used:
cpu_usage_percent: CPU usage as percentage (0.0 - 100.0)memory_usage_percent: Memory usage as percentage (0.0 - 100.0)memory_available_bytes: Available memory in bytesload_avg_1m: 1-minute load averageactive_connections: Number of active connectionsrequests_per_second: Request ratequeue_depth: Request queue depth
§Example
use serde_json::json;
let metadata = json!({
"cpu_usage_percent": 45.5,
"memory_usage_percent": 62.0,
"custom_metric": "value"
});Aliased Type§
pub enum NodeMetadata {
Null,
Bool(bool),
Number(Number),
String(String),
Array(Vec<Value>),
Object(Map<String, Value>),
}Variants§
Null
Represents a JSON null value.
let v = json!(null);Bool(bool)
Represents a JSON boolean.
let v = json!(true);Number(Number)
Represents a JSON number, whether integer or floating point.
let v = json!(12.5);String(String)
Represents a JSON string.
let v = json!("a string");Array(Vec<Value>)
Represents a JSON array.
let v = json!(["an", "array"]);Object(Map<String, Value>)
Represents a JSON object.
By default the map is backed by a BTreeMap. Enable the preserve_order
feature of serde_json to use IndexMap instead, which preserves
entries in the order they are inserted into the map. In particular, this
allows JSON data to be deserialized into a Value and serialized to a
string while retaining the order of map keys in the input.
let v = json!({ "an": "object" });