pub struct CooperationConfig {
pub enabled: bool,
pub heartbeat_seconds: u64,
pub expiry_seconds: u64,
pub seeds: Vec<String>,
pub repository: Option<String>,
}Expand description
Cooperation settings: whether this runtime links to the trusted runtimes of its repository, how often it proves it is alive, when a silent runtime counts as gone, and which endpoints to dial when discovery cannot find them.
Every field has a default that is safe on its own, so a declaration that says nothing about cooperation still behaves as intended: links are on, but a link needs a trusted peer of the same repository, and under the default trust policy there is none until a person lists a key.
use majordomus_cli::mesh::config::{CooperationConfig, DEFAULT_EXPIRY, DEFAULT_HEARTBEAT};
let default = CooperationConfig::default();
assert!(default.enabled && default.seeds.is_empty() && default.repository.is_none());
assert!(
default.expiry_seconds >= 3 * default.heartbeat_seconds,
"one lost round must never expire a runtime",
);
// and what a declaration leaves out, it gets
let stated: CooperationConfig =
serde_json::from_value(serde_json::json!({ "seeds": ["http://10.0.0.2:8742"] })).unwrap();
assert_eq!(stated.seeds, ["http://10.0.0.2:8742"]);
assert_eq!(stated.heartbeat_seconds, DEFAULT_HEARTBEAT);
assert_eq!(stated.expiry_seconds, DEFAULT_EXPIRY);Fields§
§enabled: boolWhether links open at all. On by default once the mesh is enabled: a link needs a
trusted peer of the same repository, so under the default deny_unknown policy
with an empty allowlist nothing links until a person lists a key.
heartbeat_seconds: u64Seconds between heartbeats: one beat and one sync per link per interval.
expiry_seconds: u64Seconds of silence after which a runtime is expired: its sessions end and its claims stop excluding. At least three heartbeats, so one lost round never expires anyone.
seeds: Vec<String>Endpoints (http://host:port) to dial whether or not discovery heard them: a
static fleet, or a segment neither multicast nor a rendezvous reaches.
repository: Option<String>The repository’s mesh identity, declared rather than derived from its root commits: what a shallow clone needs, and what separates two repositories sharing a history.
Implementations§
Source§impl CooperationConfig
impl CooperationConfig
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Refuse the settings that cannot work: a zero heartbeat, an expiry under three
heartbeats (one lost round would expire a live runtime), a seed that is not
http://host:port, an empty or oversized declared repository.
use majordomus_cli::mesh::config::CooperationConfig;
assert!(CooperationConfig::default().validate().is_ok());
let flapping = CooperationConfig { heartbeat_seconds: 10, expiry_seconds: 15, ..Default::default() };
assert!(flapping.validate().is_err());Trait Implementations§
Source§impl Clone for CooperationConfig
impl Clone for CooperationConfig
Source§fn clone(&self) -> CooperationConfig
fn clone(&self) -> CooperationConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CooperationConfig
impl Debug for CooperationConfig
Source§impl Default for CooperationConfig
impl Default for CooperationConfig
Source§impl<'de> Deserialize<'de> for CooperationConfig
impl<'de> Deserialize<'de> for CooperationConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for CooperationConfig
impl JsonSchema for CooperationConfig
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more