{"id":40677879,"url":"https://github.com/metamx/zk-lock","last_synced_at":"2026-01-21T10:04:09.427Z","repository":{"id":2857833,"uuid":"47574432","full_name":"metamx/zk-lock","owner":"metamx","description":"distributed lock using zookeeper","archived":false,"fork":false,"pushed_at":"2023-01-11T12:44:39.000Z","size":114,"stargazers_count":11,"open_issues_count":6,"forks_count":1,"subscribers_count":40,"default_branch":"master","last_synced_at":"2025-11-03T22:21:35.823Z","etag":null,"topics":["distributed-locking","lock","locking","node","nodejs","zookeeper"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metamx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-07T19:32:36.000Z","updated_at":"2024-04-30T11:40:01.000Z","dependencies_parsed_at":"2023-01-13T12:07:57.627Z","dependency_job_id":null,"html_url":"https://github.com/metamx/zk-lock","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/metamx/zk-lock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metamx%2Fzk-lock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metamx%2Fzk-lock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metamx%2Fzk-lock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metamx%2Fzk-lock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metamx","download_url":"https://codeload.github.com/metamx/zk-lock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metamx%2Fzk-lock/sbom","scorecard":{"id":637876,"data":{"date":"2025-08-11","repo":{"name":"github.com/metamx/zk-lock","commit":"60ed4a2443edbf253a9686e5703ccf83a3dc102a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.6,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":2,"reason":"Found 6/21 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 18 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"15 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-qh2h-chj9-jffq","Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546","Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T09:46:51.676Z","repository_id":2857833,"created_at":"2025-08-21T09:46:51.677Z","updated_at":"2025-08-21T09:46:51.677Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28631936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["distributed-locking","lock","locking","node","nodejs","zookeeper"],"created_at":"2026-01-21T10:04:08.309Z","updated_at":"2026-01-21T10:04:09.410Z","avatar_url":"https://github.com/metamx.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zk-lock\n\nDistributed locking using [node-zookeeper-client](https://github.com/alexguan/node-zookeeper-client), following the\nrecipe in the [zookeeper documentation](https://zookeeper.apache.org/doc/r3.1.2/recipes.html#sc_recipes_Locks).\n\nThe library exposes a single class, `ZookeeperLock` which is both the lock object, and provides static methods for \ninitializing the configuration and acquiring locks which are already locked.\n\nAll locks are stored in a top level zookeeper folder `locks/`, can have an optional path prefix, and take a key argument\nwhich indicates the resource that should be locked. \n\nLocks must be explicitly released with the `unlock` method in order to allow other processes to obtain the lock. `unlock` will also close the zookeeper connection.\n\n## Configuration\n`serverLocator: () =\u003e Promise\u003cany\u003e` serverLocator is a service discovery/location resolving library such as [locators](https://github.com/metamx/locators),\nor anything which implements a function which takes no arguments and can return a promise of a `Location` object that has properties `host` and `port` which specify\nwhere the zookeeper server can be discovered.\n\n`pathPrefix: string` This is a prefix to add to any key which is to be locked. Note: all locks will \nstart with the path `locks/`, so with a prefix of `foo/bar`, when locking the key `baz` the zookeeper \npath will be of the form `locks/foo/bar/baz`.\n\n`sessionTimeout: number` node-zookeeper-client `sessionTimeout` parameter that is passed down to the zookeeper client.\n\n`spinDelay: number` node-zookeeper-client `spinDelay` parameter that is passed down to the zookeeper client.\n\n`retries: number` node-zookeeper-client `retries` parameter that is passed down to the zookeeper client.\n\n`failImmediate: boolean` when set to true, instead of a blocking call to `.lock`, it will fail immediately throwing a `ZookeeperLockAlreadyLockedError`\n\n`maxConcurrentHolders: number` allow multiple calls to `.lock` to grab a lock, allowing the lock to control the number of participants in an action\n\n## ZookeeperLock\n### constructor\nusage: \n```\n\tvar lock = new ZookeeperLock(config);\n  \n```\n\n### Static methods\n\n#### initialize\nusage: `ZookeeperLock.initialize(config);`\n\nInitialize a global configuration for zookeeper locks.\n\n#### lockFactory\nusage: \n```\n\tvar lock = ZookeeperLock.lockFactory();\n```\n\n#### lock\nusage:\n```\n\tZookeeperLock.lock('key').then(function (lock) {\n    \t... do stuff\n  \t});\n```\n\n### Instance methods\n#### lock\nusage:\n```\n    var lock = ZookeeperLock.lockFactory();\n    lock.lock('key').then(function() {\n    \t... do stuff\n  \t});\n```\n\n#### unlock\nusage;\n```\n    var lock = ZookeeperLock.lockFactory();\n    lock.lock('key').then(function() {\n    \t... do stuff\n    \tlock.unlock().then(function () {\n    \t    ... \n    \t});\n    });\n```\n\n### Session timeouts\nDue to the nature of zookeeper, this locking strategy is susceptible to a situation when `sessionTimeout` occurs that a lock holder can still think that they own the lock, but the key has been lost on the zookeeper server. To handle this, `ZookeeperLock` exposes a `signal` property that emits a `lost` event when a `sessionTimeout` occurs, which MUST be handled by the lock holder to terminate execution.\n\nusage:\n\n```\n    var lock = ZookeeperLock.lockFactory();\n    lock.lock('key').then(function() {\n    \tlock.on('lost', function () {\n    \t\t... handle losing the lock, i.e. restart locking cycle.\n    \t});\n    });\n```\n\n\n## Development\n`npm run build` to compile.\n\nThe tests currently require a local installation of zookeeper to run successfully, specified\nby the `zkServerCommandPath` variable which is defined near the beginning of the tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetamx%2Fzk-lock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetamx%2Fzk-lock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetamx%2Fzk-lock/lists"}