New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

cluster-exclusivity

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cluster-exclusivity

Cluster wide semaphore using redis. Enables redundancy with exclusive work.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

node-cluster-exclusivity

Simple to use semaphore designed for when only one worker can do the work, but redundancy is required. Requires a shared redis instance.

Features:

  • Semaphore that survives application restarts
  • Highly configurable
  • The semaphore will timeout in the event of an unresponsive or dead application
  • Multiple locks can be created per process

Getting Started

Install:

npm install cluster-exclusivity

Create a lock:

var lock = require('cluster-exclusivity').init();

Whenever you need to, check it:

lock.ownLock(); //Returns true/false

###Lock Options In the init method, an object can be provided for options, the default of which are:

{
  host: '127.0.0.1',
  port: 6379,
  database: 0,
  lockKey: 'lockOwner',
  timeout: 5 //seconds
}

Additionally another property lockId can be specified, which replaces the auto-generated uuid used for determining who owns the lock.

Keywords

cluster

FAQs

Package last updated on 08 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts