
Security News
New Study Identifies 53 Slopsquatting Targets Across 5 Frontier LLMs
Five frontier LLMs generated the same nonexistent package names, leaving 53 available for potential slopsquatting across PyPI and npm.
distributed consensus on a single value using etcd
$ npm install locked
First create a locker that is pointing at some nodes of your etcd cluster
var locked = require('locked')
// create a locker pointing with an etcd connection string
var locker = locked('127.0.0.1:4001,127.0.0.1:4002')
// create a node - this points to a single key and represents its value locked across the cluster
var node = locker({
id:'node1', // this is auto-completed if left blank
path:'/master', // the etcd path we use for the lock
value:10 , // the value for this node
ttl:10 // we will check the lock every (ttl/2) seconds
})
// this is run when the values changes regardless of what node is elected
node.on('change', function(value, nodeid){
console.log(value + ' was written by ' + nodeid)
})
// this is run when this node has been selected
node.on('selected', function(){
console.log('this server has been elected as the master!')
})
// this starts the lock for this node
node.start()
you can also pass an existing etcdjs object:
var etcdjs = require('etcdjs')
var locker = locked(etcdjs('127.0.0.1:4001,127.0.0.1:4002'))
var locker = locked(etcdhosts)Create a new locker pointing to some of the etcd servers in your cluster - etcdhosts can be an array or a single address string.
var node = locker(path, opts)Create a node that represents a single key - other machines will have created nodes on the same path - they are all essentially competing.
Opts has the following keys:
node.start()Start the lock process for this node
node.stop()Stop the lock process for this node
node.id()Get the currently active id across the lock
node.value()Get the currently active value across the lock
node.localid()The id for this specific node
node.localvalue()The value for this specific node
node.localdata()The data string for this specific node
This is id + ':::' + value
node.isSelected()return boolean indicating if the node is currently the elected leader
node.on('change', function(value, nodeid){})This event is triggered when the lock value has changed regardless of which node was elected.
The nodeid is of the elected machine is passed as the second argument.
node.on('select', function(value){})This event is triggered when the node has been elected and it's value distributed to the cluster.
You can run logic in this function that should only be running on one server at a time.
node.on('refresh', function(value){})Triggered when the currently selected node has refreshed its value
MIT
FAQs
distributed consensus on a single value using etcd
The npm package locked receives a total of 12 weekly downloads. As such, locked popularity was classified as not popular.
We found that locked 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
Five frontier LLMs generated the same nonexistent package names, leaving 53 available for potential slopsquatting across PyPI and npm.

Security News
The White House’s Gold Eagle Initiative aims to coordinate AI-discovered vulnerabilities, validate findings, and accelerate patching across critical software.

Security News
A Shai-Hulud infection exposed Suno's source code, which shows the AI music startup stream-ripped tracks to train its models.