1.1.4 • Published 3 years ago

redlock-coordinator v1.1.4

Weekly downloads
23
License
MIT
Repository
github
Last release
3 years ago

Redlock Coordinator

Leader election through Redlock

Inspired by redis-leader

Requirements

  • Redis 2.6.12

Install

npm install redlock-coordinator

Examples

const Redis = require('io-redis');
const Leader = require('redlock-coordinator');

const coordinator = new RedlockCoordinator([
    new Redis( /* ... */),
], { key: 'admin:coordinator:lock', logger: getLogger('coordinator') });

API

new Coordinator(redis, options)

Create a new Coordinator

redis is an array of redis object like node redis, ioredis or any other compatible redis library

options

key redis key value, default: coordinator:redlock logger logger, default value: console wait Time between 2 tries getting elected (ms), default value: 1000 ttl Lock time to live in milliseconds (will be automatically released after that time), default value: 10000 renew Renew time to expand expiration time in milliseconds, default value: 5000 redlock: options for redlock, details can be confirm on redlock

elect (Promise)

Elect coordinator

resign (Promise)

Stop election and resign coordinator if I am coordinator.

isMe (Promise)

Tells if i got elected

Events

elected when your candidate become leader

resigned when your leader got revoked from his leadership

error when an error occurred, best is to exit your process

License

MIT

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.0-beta3

3 years ago

1.1.0-beta2

3 years ago

1.1.0-beta1

3 years ago

1.1.0-beta0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.1

5 years ago

1.0.0

5 years ago