configuration.rs

Overview

This file defines the configuration structures and types necessary for initializing and customizing a Chitchat instance, which is a gossip-based membership and failure detection protocol implementation. The configuration encapsulates parameters such as cluster identity, network settings, gossip intervals, seed nodes, failure detection tuning, and user-defined callbacks. It enables fine-grained control over the behavior of the Chitchat protocol, particularly around node liveness determination and key deletion handling.

Types and Structures

CatchupCallback

pub type CatchupCallback = Box<dyn Fn() + Send>;

ExtraLivenessPredicate

pub type ExtraLivenessPredicate = Box<dyn Fn(&NodeState) -> bool + Send>;

ChitchatConfig

pub struct ChitchatConfig {
    pub chitchat_id: ChitchatId,
    pub cluster_id: String,
    pub gossip_interval: Duration,
    pub listen_addr: SocketAddr,
    pub seed_nodes: Vec<String>,
    pub failure_detector_config: FailureDetectorConfig,
    pub marked_for_deletion_grace_period: Duration,
    pub catchup_callback: Option<CatchupCallback>,
    pub extra_liveness_predicate: Option<ExtraLivenessPredicate>,
}

Methods

for_test(port: u16) -> Self
pub fn for_test(port: u16) -> Self
Default Implementation (for tests)
impl Default for ChitchatConfig

Interactions with Other Components

Important Algorithms and Mechanisms

Diagram: Structure of ChitchatConfig

classDiagram
class ChitchatConfig {
+ChitchatId chitchat_id
+String cluster_id
+Duration gossip_interval
+SocketAddr listen_addr
+Vec<String> seed_nodes
+FailureDetectorConfig failure_detector_config
+Duration marked_for_deletion_grace_period
+Option<CatchupCallback> catchup_callback
+Option<ExtraLivenessPredicate> extra_liveness_predicate
+for_test(port: u16) ChitchatConfig
}
class CatchupCallback {
<<type>>
+Fn() + Send
}
class ExtraLivenessPredicate {
<<type>>
+Fn(&NodeState) -> bool + Send
}
ChitchatConfig "1" --> "0..1" CatchupCallback : catchup_callback
ChitchatConfig "1" --> "0..1" ExtraLivenessPredicate : extra_liveness_predicate
ChitchatConfig --> ChitchatId : chitchat_id
ChitchatConfig --> FailureDetectorConfig : failure_detector_config

This diagram illustrates the main ChitchatConfig struct, its fields, and its relationships to the callback types and other configuration components. The optional callbacks are represented as zero-or-one associations.