Rust

candidate

Module

[Candidate]: one option a balancer can choose, described by its state.

Contents

use utopia_balancer::Candidate;
Rust
pub struct Candidate

One option to balance between, described by a bag of named values (its state): a hostname, whether it is online, its load.

Rust
use php_std::Value;
use utopia_balancer::Candidate;

let mut worker = Candidate::default();
worker.set("hostname", Value::from("worker-1")).set("cpu", Value::from(35));

assert_eq!(worker.get("cpu"), Some(&Value::Int(35)));
assert_eq!(worker.get_or("memory", &Value::Int(0)), &Value::Int(0));
assert_eq!(worker.states().len(), 2);
Also implements From.