Skip to content

feat(cluster): add swim gossip protocol - #32

Merged
kacy merged 3 commits into
mainfrom
feat/cluster-gossip
Feb 6, 2026
Merged

feat(cluster): add swim gossip protocol#32
kacy merged 3 commits into
mainfrom
feat/cluster-gossip

Conversation

@kacy

@kacy kacy commented Feb 6, 2026

Copy link
Copy Markdown
Owner

summary

implements the swim gossip protocol for cluster membership and failure detection (phase 4, week 11):

  • message.rs: binary wire format for gossip messages

    • Ping, PingReq, Ack, Join, Welcome message types
    • NodeUpdate variants: Alive, Suspect, Dead, Left
    • compact encoding with ipv4/ipv6 support
  • gossip.rs: swim protocol engine

    • GossipConfig for timing/tuning parameters
    • GossipEngine for managing membership state
    • periodic random probing with probe timeouts
    • suspect -> dead transitions after suspicion timeout
    • incarnation numbers for refuting false suspicions
    • piggybacked state updates on all messages

what was tested

  • roundtrip encoding/decoding tests for all message types
  • gossip engine lifecycle tests (creation, add_seed, tick)
  • message handling tests (ping, join, ack)
  • cargo clippy -- -D warnings passes
  • cargo test --workspace all 216 tests pass

design considerations

  • binary format uses little-endian integers for efficiency
  • incarnation numbers follow swim paper for consistency
  • state updates are piggybacked to reduce message count
  • suspicion multiplier defaults to 5x protocol period
  • max 10 updates piggybacked per message to limit size

kacy added 3 commits February 6, 2026 07:59
implements binary encoding/decoding for SWIM gossip protocol messages:

- GossipMessage enum: Ping, PingReq, Ack, Join, Welcome
- NodeUpdate enum: Alive, Suspect, Dead, Left (piggybacked state)
- MemberInfo struct for cluster membership data
- compact binary format with little-endian integers
- supports both ipv4 and ipv6 addresses

includes roundtrip tests for all message types.
implements the core gossip protocol for failure detection:

- GossipConfig: protocol timing and tuning parameters
- GossipEngine: manages membership and failure detection
- MemberState/MemberStatus: per-node health tracking
- GossipEvent: events for member join/suspect/fail/leave

protocol features:
- periodic random probing (tick)
- probe timeout -> suspect transition
- suspicion timeout -> dead transition
- incarnation numbers for refuting false suspicions
- piggyback state updates on all messages

includes tests for engine lifecycle and message handling.
@kacy
kacy force-pushed the feat/cluster-gossip branch from 4c224b5 to 13bc2fa Compare February 6, 2026 13:04
@kacy
kacy merged commit a93006d into main Feb 6, 2026
5 checks passed
@kacy
kacy deleted the feat/cluster-gossip branch February 7, 2026 20:06
kacy added a commit that referenced this pull request Feb 11, 2026
feat(cluster): add swim gossip protocol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant