
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@clickup/distributed-locker
Advanced tools
Ensures that some long-running job with an unique key is not double scheduled in the cluster.
See also Full API documentation.
As opposed to the popular redlock algorithm, the library also tracks per-process liveness (in a separate Node thread), so the locks from a dead process are quickly reported as free to the rest of the cluster as soon as the process dies. This is extremely convenient when doing cluster-wide deployments or individual worker process restarts.
Main features:
export const db = new RedisDatabase(
// You can also use Redis Cluster here.
new Redis({
host: process.env.REDIS_WORKER_HOST,
port: process.env.REDIS_WORKER_PORT,
password: process.env.REDIS_WORKER_PASSWORD,
keyPrefix: "locker:",
})
);
const locker = new Locker({
database: {
moduleName: __file,
exportName: "db",
},
});
// ...
const res = await locker.acquireAndRun("job-key", async (heartbeat) => {
while (shouldContinue()) {
await doSomeWork();
// 1. Reports that the job is still running to refresh the lock.
// 2. If someone takes over (e.g. a network blip or event loop
// blockage), kills itself by throwing LockError exception.
await heartbeat();
}
});
// res is now either { status: LockStatus.SUCCESS }
// or { status: LockStatus.SOMEONE_ELSE_HOLDS_LOCK }
FAQs
Ensures that some long-running job with an unique key is not double scheduled in the cluster.
The npm package @clickup/distributed-locker receives a total of 13 weekly downloads. As such, @clickup/distributed-locker popularity was classified as not popular.
We found that @clickup/distributed-locker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 13 open source maintainers 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
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.