Crate memberlist_plumtree

Crate memberlist_plumtree 

Source
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§

AdaptiveBatcher
Adaptive batcher that adjusts IHave batch sizes based on network conditions.
BatcherConfig
Configuration for adaptive batching.
BatcherStats
Statistics about batching behavior.
BridgeConfig
Configuration for the Plumtree bridge.
BridgeEventDelegate
Bridge event delegate that implements Memberlist’s EventDelegate.
BroadcastEnvelope
Outgoing broadcast envelope (unencooded).
CacheHealth
Health information about the message cache.
CacheStats
Statistics about the message cache.
ChannelTransport
A simple channel-based transport that outputs (target, data) pairs.
ChannelTransportError
Error type for channel transport.
CleanupConfig
Configuration for dynamic cleanup tuning.
CleanupParameters
Tuned cleanup parameters.
CleanupStats
Statistics about cleanup performance.
CleanupTuner
Dynamic cleanup tuner that adjusts parameters based on load.
CongestionConfigquic
Congestion control configuration.
ConnectionConfigquic
Connection lifecycle configuration.
ConnectionStatsquic
Statistics for the connection manager.
DeliveryHealth
Health information about message delivery.
ExpiredGraft
Result of checking for expired Graft timers.
FailedGraft
Information about a failed Graft after max retries exhausted.
GlobalRateLimiter
Global rate limiter for all peers combined.
GraftTimer
Tracks pending Graft requests with timeouts and exponential backoff.
HealthReport
Detailed health report for the Plumtree protocol.
HealthReportBuilder
Builder for creating health reports.
IHaveQueue
Lock-free queue for pending IHave announcements.
IHaveScheduler
Scheduler for managing IHave announcement timing.
IncomingMessage
Incoming message received from a peer.
LazarusHandle
Handle for controlling the Lazarus background task.
LazarusStats
Statistics for the Lazarus seed recovery task.
MapPeerResolverquic
Simple HashMap-based peer resolver.
MemberlistStack
A complete Plumtree + Memberlist integration stack.
MessageCache
Thread-safe message cache with TTL-based eviction.
MessageId
Unique identifier for a Plumtree message.
MessagePrioritiesquic
Priority levels for different Plumtree message types.
MigrationConfigquic
Connection migration configuration.
NoopDelegate
No-op delegate for when no handler is needed.
NoopTransport
A no-op transport that discards all messages.
OutgoingMessage
Outgoing message to be sent.
PeerHealth
Health information about peer connectivity.
PeerScore
RTT and scoring data for a single peer.
PeerScoring
Peer scoring system for RTT-based topology optimization.
PeerState
Manages eager and lazy peer sets for the Plumtree protocol.
PeerStateBuilder
Builder for creating PeerState with specific configuration.
PeerStats
Statistics about peer state.
PeerTopology
Snapshot of the current peer topology.
PendingIHave
Pending IHave entry in the queue.
Plumtree
Core Plumtree broadcast implementation.
PlumtreeBridge
Plumtree-Memberlist integration bridge.
PlumtreeConfig
Configuration options for the Plumtree protocol.
PlumtreeEventHandler
Event handler that synchronizes memberlist events to Plumtree.
PlumtreeHandle
Handle for interacting with Plumtree from the network layer.
PlumtreeMemberlist
Combined Plumtree + Memberlist system.
PlumtreeNodeDelegate
Delegate that intercepts messages for Plumtree protocol.
PlumtreeQuicConfigquic
Plumtree-specific QUIC optimizations.
PlumtreeRunnerDeprecated
Legacy runner that sends all messages to a single broadcast channel.
PlumtreeRunnerBuilderDeprecated
Builder for creating and configuring a PlumtreeRunner.
PlumtreeRunnerWithTransport
Runs all Plumtree background tasks with proper unicast transport.
PlumtreeStackBuilder
Builder for creating a fully configured Plumtree stack.
PoolConfig
Configuration for the pooled transport.
PoolStats
Statistics for the pooled transport.
PooledTransport
Pooled transport wrapper that provides connection management.
QuicConfigquic
QUIC transport configuration with modular sub-configs.
QuicStatsquic
QUIC transport statistics.
QuicTransportquic
QUIC-based transport for Plumtree message delivery.
RateLimiter
Token bucket rate limiter for per-peer rate limiting.
ScoringConfig
Configuration for peer scoring.
ScoringStats
Statistics about the peer scoring system.
SeenMapStats
Statistics about the seen map (deduplication map).
StreamConfigquic
Stream multiplexing configuration.
TlsConfigquic
TLS/certificate configuration.
ZeroRttConfigquic
0-RTT early data configuration.

Enums§

AddPeerResult
Result of adding a peer with auto-classification.
BackpressureHint
Hint about whether to apply backpressure or drop messages.
CleanupReason
Reason for cleanup parameter decision.
CongestionControllerquic
Congestion control algorithm.
EfficiencyTrend
Efficiency trend direction.
Error
Errors that can occur during Plumtree operations.
ErrorKind
Classification of error types for retry decisions.
HealthStatus
Overall health status of the Plumtree protocol.
MemberlistStackError
Errors that can occur when using MemberlistStack.
MessageTag
Message type tags for encoding.
PlumtreeMessage
Protocol message types for Plumtree.
PlumtreeMessageRef
Reference to a Plumtree message (for zero-copy operations).
PooledTransportError
Error type for pooled transport.
PressureTrend
Pressure trend direction.
QuicErrorquic
Error type for QUIC transport operations.
RemovePeerResult
Result of removing a peer.

Traits§

AddressExtractor
Trait for extracting socket address from memberlist node addresses.
IdCodec
Trait for encoding and decoding node IDs for network transmission.
PeerResolverquic
Trait for resolving peer IDs to socket addresses.
PlumtreeDelegate
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.