Expand description
§memberlist-plumtree
Plumtree (Epidemic Broadcast Trees) implementation built on top of memberlist.
Plumtree combines the efficiency of tree-based broadcast (O(n) messages) with the reliability of gossip protocols through a hybrid push/lazy-push approach.
§How Plumtree Works
- Eager Push: Full messages are sent along spanning tree edges (eager peers)
- Lazy Push: Message announcements (IHave) are sent to non-tree peers (lazy peers)
- Self-Healing: When a node receives an IHave for a missing message, it grafts the sender into its eager set, automatically repairing the tree
§Example
ⓘ
use memberlist_plumtree::{Plumtree, PlumtreeConfig, PlumtreeDelegate};
use bytes::Bytes;
// Define a delegate to receive messages
struct MyDelegate;
impl PlumtreeDelegate for MyDelegate {
fn on_deliver(&self, msg_id: MessageId, payload: Bytes) {
println!("Received message: {:?}", payload);
}
}
// Create Plumtree instance
let (plumtree, handle) = Plumtree::new(
node_id,
PlumtreeConfig::lan(),
MyDelegate,
);
// Add peers (from memberlist membership)
plumtree.add_peer(peer_id);
// Broadcast a message to all nodes
let msg_id = plumtree.broadcast(b"hello world").await?;Modules§
- memberlist
- Re-export memberlist-core types for convenience
- persistence
- Persistence module for saving and loading known peer addresses.
- testing
- Chaos testing utilities for Plumtree protocol.
Structs§
- Adaptive
Batcher - Adaptive batcher that adjusts IHave batch sizes based on network conditions.
- Batcher
Config - Configuration for adaptive batching.
- Batcher
Stats - Statistics about batching behavior.
- Bridge
Config - Configuration for the Plumtree bridge.
- Bridge
Event Delegate - Bridge event delegate that implements Memberlist’s EventDelegate.
- Broadcast
Envelope - Outgoing broadcast envelope (unencooded).
- Cache
Health - Health information about the message cache.
- Cache
Stats - Statistics about the message cache.
- Channel
Transport - A simple channel-based transport that outputs (target, data) pairs.
- Channel
Transport Error - Error type for channel transport.
- Cleanup
Config - Configuration for dynamic cleanup tuning.
- Cleanup
Parameters - Tuned cleanup parameters.
- Cleanup
Stats - Statistics about cleanup performance.
- Cleanup
Tuner - Dynamic cleanup tuner that adjusts parameters based on load.
- Congestion
Config quic - Congestion control configuration.
- Connection
Config quic - Connection lifecycle configuration.
- Connection
Stats quic - Statistics for the connection manager.
- Delivery
Health - Health information about message delivery.
- Expired
Graft - Result of checking for expired Graft timers.
- Failed
Graft - Information about a failed Graft after max retries exhausted.
- Global
Rate Limiter - Global rate limiter for all peers combined.
- Graft
Timer - Tracks pending Graft requests with timeouts and exponential backoff.
- Health
Report - Detailed health report for the Plumtree protocol.
- Health
Report Builder - Builder for creating health reports.
- IHave
Queue - Lock-free queue for pending IHave announcements.
- IHave
Scheduler - Scheduler for managing IHave announcement timing.
- Incoming
Message - Incoming message received from a peer.
- Lazarus
Handle - Handle for controlling the Lazarus background task.
- Lazarus
Stats - Statistics for the Lazarus seed recovery task.
- MapPeer
Resolver quic - Simple HashMap-based peer resolver.
- Memberlist
Stack - A complete Plumtree + Memberlist integration stack.
- Message
Cache - Thread-safe message cache with TTL-based eviction.
- Message
Id - Unique identifier for a Plumtree message.
- Message
Priorities quic - Priority levels for different Plumtree message types.
- Migration
Config quic - Connection migration configuration.
- Noop
Delegate - No-op delegate for when no handler is needed.
- Noop
Transport - A no-op transport that discards all messages.
- Outgoing
Message - Outgoing message to be sent.
- Peer
Health - Health information about peer connectivity.
- Peer
Score - RTT and scoring data for a single peer.
- Peer
Scoring - Peer scoring system for RTT-based topology optimization.
- Peer
State - Manages eager and lazy peer sets for the Plumtree protocol.
- Peer
State Builder - Builder for creating PeerState with specific configuration.
- Peer
Stats - Statistics about peer state.
- Peer
Topology - Snapshot of the current peer topology.
- PendingI
Have - Pending IHave entry in the queue.
- Plumtree
- Core Plumtree broadcast implementation.
- Plumtree
Bridge - Plumtree-Memberlist integration bridge.
- Plumtree
Config - Configuration options for the Plumtree protocol.
- Plumtree
Event Handler - Event handler that synchronizes memberlist events to Plumtree.
- Plumtree
Handle - Handle for interacting with Plumtree from the network layer.
- Plumtree
Memberlist - Combined Plumtree + Memberlist system.
- Plumtree
Node Delegate - Delegate that intercepts messages for Plumtree protocol.
- Plumtree
Quic Config quic - Plumtree-specific QUIC optimizations.
- Plumtree
Runner Deprecated - Legacy runner that sends all messages to a single broadcast channel.
- Plumtree
Runner Builder Deprecated - Builder for creating and configuring a PlumtreeRunner.
- Plumtree
Runner With Transport - Runs all Plumtree background tasks with proper unicast transport.
- Plumtree
Stack Builder - Builder for creating a fully configured Plumtree stack.
- Pool
Config - Configuration for the pooled transport.
- Pool
Stats - Statistics for the pooled transport.
- Pooled
Transport - Pooled transport wrapper that provides connection management.
- Quic
Config quic - QUIC transport configuration with modular sub-configs.
- Quic
Stats quic - QUIC transport statistics.
- Quic
Transport quic - QUIC-based transport for Plumtree message delivery.
- Rate
Limiter - Token bucket rate limiter for per-peer rate limiting.
- Scoring
Config - Configuration for peer scoring.
- Scoring
Stats - Statistics about the peer scoring system.
- Seen
MapStats - Statistics about the seen map (deduplication map).
- Stream
Config quic - Stream multiplexing configuration.
- TlsConfig
quic - TLS/certificate configuration.
- Zero
RttConfig quic - 0-RTT early data configuration.
Enums§
- AddPeer
Result - Result of adding a peer with auto-classification.
- Backpressure
Hint - Hint about whether to apply backpressure or drop messages.
- Cleanup
Reason - Reason for cleanup parameter decision.
- Congestion
Controller quic - Congestion control algorithm.
- Efficiency
Trend - Efficiency trend direction.
- Error
- Errors that can occur during Plumtree operations.
- Error
Kind - Classification of error types for retry decisions.
- Health
Status - Overall health status of the Plumtree protocol.
- Memberlist
Stack Error - Errors that can occur when using
MemberlistStack. - Message
Tag - Message type tags for encoding.
- Plumtree
Message - Protocol message types for Plumtree.
- Plumtree
Message Ref - Reference to a Plumtree message (for zero-copy operations).
- Pooled
Transport Error - Error type for pooled transport.
- Pressure
Trend - Pressure trend direction.
- Quic
Error quic - Error type for QUIC transport operations.
- Remove
Peer Result - Result of removing a peer.
Traits§
- Address
Extractor - Trait for extracting socket address from memberlist node addresses.
- IdCodec
- Trait for encoding and decoding node IDs for network transmission.
- Peer
Resolver quic - Trait for resolving peer IDs to socket addresses.
- Plumtree
Delegate - Delegate trait for receiving Plumtree events.
- Transport
- Transport trait for sending Plumtree messages.
Functions§
- create_
plumtree_ with_ channels - Simple function to create a Plumtree system with channels.
- decode_
plumtree_ envelope - Decode a Plumtree envelope extracting sender ID and message.
- decode_
plumtree_ message - Try to decode a Plumtree message from received bytes (without sender).
- encode_
plumtree_ envelope - Encode a Plumtree message with sender identity for transmission.
- encode_
plumtree_ envelope_ into - Encode a Plumtree envelope directly into an existing buffer.
- encode_
plumtree_ message - Encode a Plumtree message for transmission via memberlist.
- envelope_
encoded_ len - Calculate the encoded length of a Plumtree envelope.
- is_
plumtree_ message - Check if data is a Plumtree message.
Type Aliases§
- Result
- Result type alias for Plumtree operations.