Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
enrise-lock
Advanced tools
An elasticsearch based lock mechanism for resources and ownership.
This module provides abstraction methods to lock a resource with an owner. The owner is the name of the process requesting a lock. The resource would be the specific element/index/endpoint/etc.. that requires locking.
NPM: npm install enrise-lock --save
Yarn: yarn add enrise-lock
Require and instantiate the locker.
const lock = new require('enrise-lock')(config: Object);
Where config
is an object with the following options. Type is optional, the rest is mandatory.
esClient: elasticsearch
: An elasticsearch client for the lock module to use. This can either be an elasticsearch or an enrise-esclient instance.index: String
: The elasticsearch index that will be used to store all lock-documents.owner: String
: The name of the process that is looking to place the lock.[type: String]
: The index-type that will be used to store all lock-documents. This will default to 'lockdocument'
.lock.acquire(resource: String, callback: function)
Set a lock for resource: resource
. Callback will be called with parameters [err, success: boolean]
. The success paramater will be false if a lock already exists.
lock.release(resource: String, callback: function)
Release a lock for resource: resource
. Callback will be called with parameter [err]
.
lock.isLocked(resource: String, callback: function)
Check if a resource is locked. Callback will be called with parameters [err, isLocked: boolean]
.
lock.list(callback: function)
Retrieve a list of all current locks. Callback will be called with parameters [err, locks: Object]
. Where the key in locks represents the resource and the value an object with the owner.
lock.delete(callback: function)
Delete the entire lock-index. Callback will be called with parameter [err]
.
const lock = new require('enrise-lock')({
esClient: new require('elasticsearch').Client(),
index: 'globallock',
type: 'lockdocument',
owner: 'api'
});
// Set lock
lock.acquire('my-resource', (err, success) => {
// Do some asynchronous operation
// ...
// Release lock
lock.release('my-resource', (err, success) => {
// ...
});
});
FAQs
Lock functionality used within Enrise projects and module's
The npm package enrise-lock receives a total of 3 weekly downloads. As such, enrise-lock popularity was classified as not popular.
We found that enrise-lock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.