Documentation
¶
Index ¶
- type ChaosAPI
- type Command
- type ConfigAPI
- type KVStore
- func (kv *KVStore) HandleCluster(w http.ResponseWriter, r *http.Request)
- func (kv *KVStore) HandleDelete(w http.ResponseWriter, r *http.Request)
- func (kv *KVStore) HandleEvents(w http.ResponseWriter, r *http.Request)
- func (kv *KVStore) HandleGet(w http.ResponseWriter, r *http.Request)
- func (kv *KVStore) HandlePut(w http.ResponseWriter, r *http.Request)
- func (kv *KVStore) HandleStatus(w http.ResponseWriter, r *http.Request)
- func (kv *KVStore) RegisterRoutes(mux *http.ServeMux)
- func (kv *KVStore) Start()
- func (kv *KVStore) Stop()
- type LogAPI
- type Metrics
- type Server
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChaosAPI ¶ added in v0.2.0
type ChaosAPI struct {
// contains filtered or unexported fields
}
ChaosAPI exposes HTTP control endpoints for the NetworkProxy attached to this node, plus cluster-wide orchestration endpoints that fan out to peers.
Per-node endpoints manipulate only the local proxy (affect this node's outbound traffic). Cluster endpoints let the UI issue a single request that installs matching rules on every node — essential for symmetric partitions and preset scenarios.
func NewChaosAPI ¶ added in v0.2.0
func (*ChaosAPI) RegisterRoutes ¶ added in v0.2.0
type ConfigAPI ¶ added in v0.2.0
type ConfigAPI struct {
// contains filtered or unexported fields
}
func NewConfigAPI ¶ added in v0.2.0
func (*ConfigAPI) RegisterRoutes ¶ added in v0.2.0
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
KVStore is the state machine: map[string]string driven by the Raft commit log. Only applyLoop() writes to data; HTTP handlers read from it.
func NewKVStore ¶
func (*KVStore) HandleCluster ¶ added in v0.2.0
func (kv *KVStore) HandleCluster(w http.ResponseWriter, r *http.Request)
Handles: GET /api/cluster — aggregated snapshot across all peers.
func (*KVStore) HandleDelete ¶
func (kv *KVStore) HandleDelete(w http.ResponseWriter, r *http.Request)
Handles: DELETE /keys/{key}
func (*KVStore) HandleEvents ¶ added in v0.2.0
func (kv *KVStore) HandleEvents(w http.ResponseWriter, r *http.Request)
Handles: GET /api/events — Server-Sent Events. Emits a "status" frame every 500ms and diff events (leader_change, term_change, node_down, node_up) whenever the snapshot changes.
func (*KVStore) HandleGet ¶
func (kv *KVStore) HandleGet(w http.ResponseWriter, r *http.Request)
Handles: GET /keys/{key}
func (*KVStore) HandlePut ¶
func (kv *KVStore) HandlePut(w http.ResponseWriter, r *http.Request)
Handles: PUT /keys/{key} body: {"value":"..."}
func (*KVStore) HandleStatus ¶
func (kv *KVStore) HandleStatus(w http.ResponseWriter, r *http.Request)
Handles: GET /status — returns node's Raft state as JSON.
func (*KVStore) RegisterRoutes ¶
RegisterRoutes wires all KVStore handlers into an HTTP mux.
type LogAPI ¶ added in v0.2.0
type LogAPI struct {
// contains filtered or unexported fields
}
LogAPI exposes the Raft log for visualization in the dashboard. Each node serves its own log; the cluster endpoint fans out to every peer.
func (*LogAPI) RegisterRoutes ¶ added in v0.2.0
type Metrics ¶
type Metrics struct {
CurrentTerm prometheus.Gauge
State prometheus.Gauge
CommittedIndex prometheus.Gauge
AppliedIndex prometheus.Gauge
LogEntriesTotal prometheus.Counter
ElectionsTotal prometheus.Counter
LeaderChanges prometheus.Counter
ReplicationLag *prometheus.HistogramVec
WALFsyncDuration prometheus.Histogram
}
This holds all Prometheus instruments for the Raftly node. All prometheus types are safe for concurrent use.
func NewMetrics ¶
func NewMetrics() *Metrics
func (*Metrics) Update ¶
func (m *Metrics) Update(status raft.NodeStatus, prevLeader string)
Refreshes all gauges from the current node status. We call this on a regular interval (every second) from a background goroutine. prevLeader is the leaderID from the previous call - used to detect transitions.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server owns and manages the lifecycle of every Raftly subsystem.
type ServerConfig ¶
type ServerConfig struct {
Raft *raft.Config
GRPCAddr string // this node's gRPC listen address (Raft peer communication)
HttpAddr string // this node's HTTP listen address (client API + /metrics)
HTTPPeers map[string]string // nodeID → HTTP address for ALL nodes (including self, for redirects)
}
Holds everything to start a Raftly server node