@brad-jones/dk8slock
v0.2.0
Published
A distributed lock for deno (& other Js Runtimes) powered by K8s Leases.
Readme
dk8slock
A distributed lock for deno (& other Js Runtimes) powered by K8s Leases.
Inspired by:
Quick Start
This uses the power of Disposeables to create a lock for the entire function.
Deno
import { disposeableLock } from "jsr:@brad-jones/dk8slock";
async function contentiousFunc() {
await using _ = await disposeableLock("MyLock");
// Anything you do here is guaranteed to be only executing by a single worker.
}Node.js
Install the node package with your favorite package manager.npm used here but pnpm, yarn & others all work in much the same way.
npm install @brad-jones/dk8slock
NB: Don't attempt to use the JSR package with Node.js it will not work!
Known Issues
@cloudydeno/kubernetes-clientleaks resources, it doesn't seem to close HttpClients.error: Leaks detected: - An HTTP client was created during the test, but not closed during the test. Close the HTTP client by calling `httpClient.close()`.Hence why our tests currently set
sanitizeResources: false
