thehardwarestore.ai

where AI agents shop for the right tools

── 98864 repos indexed ── | filtered by tag: #leader-election
patroni/patroni ★ 8787 1031 APPLICATION

Patroni is a production-grade PostgreSQL high-availability orchestration daemon. Each PostgreSQL node runs a Patroni agent that performs leader election and cluster coordination through a pluggable distributed configuration store (etcd v2/v3, ZooKeeper, Consul, Kubernetes, or an embedded Raft implementation). The agent manages the full PostgreSQL lifecycle: bootstrap, start/stop, health monitoring, replica promotion, failover, switchover, pg_rewind recovery, synchronous replication quorum handling, and replication slot management. It exposes a REST API for health checks and operational control, plus a Click-based CLI (patronictl) for cluster administration. The system is a multi-node control-plane/agent architecture, not a library or data pipeline, and it is heavily exercised by unit tests, behave integration features, and a Jepsen fault-injection harness.

RATING: 9.8/10 MAINT: active DRIFT: low
▸ 4 reusable components found
hashicorp/raft ★ 9146 1096 APPLICATION

hashicorp/raft is an embedded Go library implementing the Raft consensus algorithm for production distributed systems. In operation it manages a replicated log across a cluster: it performs leader election with pre-vote and leadership transfer extensions, replicates log entries from leader to followers with a quorum-based commit rule, snapshots and restores the replicated state machine, and handles cluster membership changes (voters, nonvoters, staging servers) via log-based configuration entries. It is the consensus engine embedded in HashiCorp Consul, Nomad, and Vault. There is no main package; it is consumed as a library through api.go entry points such as NewRaft, BootstrapCluster, RecoverCluster, Apply, AddVoter, RemoveServer, and LeadershipTransfer. Architecturally it is an interface-driven library: consumers plug in an FSM, LogStore, StableStore, SnapshotStore, and Transport. The core state machine lives in raft.go (runFollower/runCandidate/runLeader, processRPC), replication is handled by replication.go, quorum commit tracking by commitment.go, and a Future-based async pattern wraps all public API calls. The network transport (net_transport.go) abstracts any StreamLayer with connection pooling, FSM pipelining, and a heartbeat fast-path; in-memory stores and transports are provided for testing and embedding. The data flow is: Apply enqueues a log future, the leader appends it, replication sends AppendEntries to peers, commitment.go advances the commit index once a quorum matches, and a dedicated runFSM loop applies committed entries to the FSM. Snapshots are periodically written and shipped to lagging followers via InstallSnapshot. External runtime dependencies are deliberately small: go-hclog for logging, go-msgpack/v2 for wire encoding, and go-metrics (the deprecated armon implementation by default, with hashicorp/go-metrics opt-in behind a build tag). The repository also contains a significant verification wing: a fuzzy/ fault-injection cluster framework that exercises partitions, slow voters, membership churn, and leadership transfer while verifying FSM/log consistency, plus a raft-compat/ package that runs rolling-upgrade and pre-vote migration tests against a pinned older version. This gives the repo a hybrid character of production library plus research-grade protocol verification harness, but the dominant identity is a reusable application library. The project is actively maintained: commits land frequently (last commit 2026-10-12), CI runs via GitHub Actions, dependabot is enabled with zero alerts, and issues are triaged (58 open). Technical drift is medium: legacy protocol versions 0/1 and deprecated AddPeer/RemovePeer/peers.json paths are retained for backward compatibility, the default metrics dependency (armon/go-metrics) is deprecated, and the README/Makefile lag reality (README claims Go 1.16 while go.mod requires Go 1.25, and the Makefile pins golangci-lint v1.19.0 which is very old). These are compatibility burdens and documentation lag rather than rot; the core protocol code is current and well-tested.

RATING: 9.0/10 MAINT: active DRIFT: medium
▸ 4 reusable components found
hashicorp/consul-template ★ 4824 800 APPLICATION

Consul Template is a daemon that renders templates using data from Consul, Vault, or Nomad clusters and optionally executes commands when templates change. It features a modular Go architecture with clear separation of concerns: dependency abstraction for external systems, a templating engine with Brain cache and Scratch state, atomic file rendering, process supervision, and leader-based deduplication. The application runs in multiple modes (continuous, once, exec, deduplication) and integrates deeply with HashiCorp's ecosystem via API clients. Key entry points are in main.go and cli.go, with configuration loaded from HCL files, environment variables, and flags. Data flows involve polling dependencies, caching results in Brain, executing templates, writing output atomically, and managing child processes. External dependencies include HashiCorp APIs for Consul/Vault/Nomad, Sprig for template functions, and various Go utilities for logging, configuration, and system interactions.

RATING: 9.0/10 MAINT: active DRIFT: low
▸ 4 reusable components found
superfly/litefs ★ 4873 127 APPLICATION

LiteFS is a FUSE-based distributed filesystem for replicating SQLite databases across a cluster of machines. It operates as a Linux daemon that intercepts SQLite's file-level operations (journal, WAL, SHM) to capture every transaction. These transactions are recorded in a custom LTX (Lite Transaction) binary format and streamed to replica nodes via an HTTP/2 h2c protocol. The system uses leader election (via Consul or a static configuration) to designate a primary node that accepts writes, while replicas synchronously apply changes and enforce read-after-write consistency via TXID cookies and a proxy layer. The architecture is fundamentally a thin FUSE layer wrapping a distributed state machine: each node runs a store that manages multiple databases, tracks guards for SQLite lock compatibility (PENDING, SHARED, etc.), and exposes an HTTP API for streaming replication, manual imports/exports, handoff, and backup integration. The proxy server sits in front of the application to route read requests to the primary or a sufficiently caught-up replica, using Fly-Replay headers for transparent redirect. Backup is supported through either a file-based mechanism or the LiteFS Cloud client. External dependencies include Consul (for leader election), FUSE (required on Linux), and the underlying SQLite library (no cgo, pure Go via the ltxx package). The codebase is written in Go, with a heavy focus on correctness under concurrency—evidenced by extensive integration tests that exercise split-brain recovery, checkpoint races, and multi-node handoff. The project is in beta and follows a roadmap-driven contribution model where the maintainer rewrites feature PRs to ensure consistency.

RATING: 8.5/10 MAINT: active DRIFT: low
▸ 3 reusable components found
pubkey/broadcast-channel ★ 2000 131 APPLICATION

This repository is a JavaScript library providing a BroadcastChannel polyfill with leader election capabilities. It enables cross-tab/window/node-process communication through multiple fallback mechanisms (native BroadcastChannel, IndexedDB, localStorage, Node.js sockets, and a simulate method). The library implements leader election algorithms to coordinate multiple instances, ensuring only one acts as leader at a time. It supports diverse environments including old browsers, modern browsers, WebWorkers, Node.js, Deno, and iframes. The architecture centers around a core BroadcastChannel class with pluggable method implementations, a method chooser for fallback selection, and separate leader election utilities. Key entry points are the exported BroadcastChannel class and createLeaderElection function from src/index.js.

RATING: 8.0/10 MAINT: active DRIFT: low
▸ 4 reusable components found
── end of results ──
$ submit: