A consensus library for Node.js microservices implementing a simplified Raft algorithm using Redis as the communication medium. Version 0.1.1 is the latest stable release; the project is in early development with no frequent releases. It provides automatic leader election among instances of the same service kind, supporting leader/follower roles, messaging, and instance metadata. Unlike full Raft implementations, this is a simplified approach focused on microservice coordination, requiring only Redis and offering easy integration without complex setup.
npm install node-raft-redisNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Create a Candidate instance, listen for events (elected, defeated, message), and start the consensus process.
Use either redis: { host: '...', port: 6379 } or redis: { url: 'redis://...' }, not both.Always provide a valid string for 'kind'.
Check if candidate is leader by listening to 'elected' and only call reelect from that context.
Use setMeta() method after candidate.start() to set metadata.
Ensure the code runs in a Node.js environment with a Redis server accessible.
Start Redis server or set correct connection options via redis option in constructor.
Ensure the event listener uses correct signature: (payload) => { ... } where payload has 'message' and 'from' properties. If using custom events, check for typos.Provide a valid string for 'kind' in the Candidate constructor.
Check candidate state or call candidate.stop() before starting again.