How hlccd/hraft works
hraft is a Go library for synchronizing messages across a Raft-style TCP cluster. A caller creates a node with NewRaft, submits messages with Put, and reads delivered messages with Get; the leader broadcasts messages to peers, while follower messages are forwarded to the leader. Separate runtime branches handle joining and membership updates, keepalives, and leader election. The excerpts show these call paths and protocol framing; other README-level capabilities are limited to the stated cluster synchronization purpose.
Main entry points: cluster.go Join and membership · protocol.go Protocol transport · shunt.go Message dispatcher · raft.go Raft API
Components 15
Client API
- Raft API
raft.go - Message loop
raft.go - Message channels
raft.go
Node Runtime
- TCP listener
raft.go - Message dispatcher
shunt.go
Cluster Membership
- Peer state
core.go - Join and membership
cluster.go - Address mapping
address.go - Keepalive sync
cluster.go
Leader Election
- Election coordinator
vote.go - Vote handler
vote.go
TCP Protocol
- Protocol transport
protocol/protocol.go - Message codec
protocol/message.go
Other components
- Library caller
- Cluster peers
Connections 28
- Library caller → Raft API: creates, puts, gets
raft.go - Raft API → Join and membership: joins cluster
raft.go - Raft API → TCP listener: starts listener
raft.go - Raft API → Message loop: starts loop
raft.go - Message loop → Message channels: reads and writes
raft.go - Message loop → Protocol transport: sends messages
raft.go - Message loop → Message channels: delivers locally
raft.go - TCP listener → Protocol transport: reads messages
raft.go - TCP listener → Message dispatcher: dispatches
raft.go - Message dispatcher → Join and membership: routes membership
shunt.go - Message dispatcher → Keepalive sync: routes keepalive
shunt.go - Message dispatcher → Vote handler: routes votes
shunt.go - Message dispatcher → Message channels: delivers messages
shunt.go - Message dispatcher → Join and membership: routes peer messages
shunt.go - Join and membership → Protocol transport: sends membership messages
cluster.go - Join and membership → Peer state: updates peers
cluster.go - Join and membership → Address mapping: translates addresses
cluster.go - Join and membership → Cluster peers: accepts and informs
cluster.go - Keepalive sync → Protocol transport: sends heartbeats
cluster.go - Keepalive sync → Peer state: reads peer list
cluster.go - Keepalive sync → Cluster peers: maintains membership
cluster.go - Election coordinator → Protocol transport: requests votes
vote.go - Election coordinator → Peer state: reads peer state
vote.go - Election coordinator → Vote handler: coordinates votes
vote.go - Vote handler → Protocol transport: replies and reads
vote.go - Vote handler → Join and membership: rejoins winner
vote.go - Protocol transport → Message codec: encodes and parses
protocol/protocol.go - Protocol transport → Cluster peers: exchanges TCP messages
protocol/protocol.go