{"id":17817911,"url":"https://github.com/0xtheprodev/distributed-lock","last_synced_at":"2026-03-10T06:04:43.467Z","repository":{"id":249504464,"uuid":"831366824","full_name":"0xTheProDev/distributed-lock","owner":"0xTheProDev","description":"Distributed Lock to execute Mutual Exclusion of a Shared Resource in a Microservice Architecture","archived":false,"fork":false,"pushed_at":"2026-01-05T22:14:57.000Z","size":1534,"stargazers_count":3,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-30T02:53:13.721Z","etag":null,"topics":["distributed-lock","distributed-systems","hacktoberfest","microservices","mutex","nestjs","nodejs","redis","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xTheProDev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"0xTheProDev"}},"created_at":"2024-07-20T10:49:18.000Z","updated_at":"2025-10-24T12:11:54.000Z","dependencies_parsed_at":"2024-08-21T11:46:09.183Z","dependency_job_id":"d6244590-8251-4484-af31-efd558827895","html_url":"https://github.com/0xTheProDev/distributed-lock","commit_stats":null,"previous_names":["0xtheprodev/distributed-lock"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/0xTheProDev/distributed-lock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xTheProDev%2Fdistributed-lock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xTheProDev%2Fdistributed-lock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xTheProDev%2Fdistributed-lock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xTheProDev%2Fdistributed-lock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xTheProDev","download_url":"https://codeload.github.com/0xTheProDev/distributed-lock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xTheProDev%2Fdistributed-lock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30326878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T05:25:20.737Z","status":"ssl_error","status_checked_at":"2026-03-10T05:25:17.430Z","response_time":106,"last_error":"SSL_read: 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-lock","distributed-systems","hacktoberfest","microservices","mutex","nestjs","nodejs","redis","typescript"],"created_at":"2024-10-27T16:46:42.770Z","updated_at":"2026-03-10T06:04:43.436Z","avatar_url":"https://github.com/0xTheProDev.png","language":"TypeScript","funding_links":["https://github.com/sponsors/0xTheProDev"],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-configure-file { \"MD033\": false } --\u003e\n\n# Distributed Lock\n\n[![Distributed Lock Icon](.github/assets/distributed-lock-original.png)](https://github.com/0xTheProDev/distributed-lock)\n\n---\n\n[![Regression](https://github.com/0xTheProDev/distributed-lock/actions/workflows/regression.yml/badge.svg?style=for-the-badge)](https://github.com/0xTheProDev/distributed-lock/actions/workflows/regression.yml)\n[![Release](https://github.com/0xTheProDev/distributed-lock/actions/workflows/release.yml/badge.svg?style=for-the-badge)](https://github.com/0xTheProDev/distributed-lock/actions/workflows/release.yml)\n\n[![Sponsor](https://img.shields.io/badge/sponsor-30363D?style=for-the-badge\u0026logo=GitHub-Sponsors\u0026logoColor=#white)](https://github.com/sponsors/0xTheProDev)\n[![Node LTS](https://img.shields.io/node/v-lts/@theprodev/distributed-lock?style=for-the-badge)](https://nodejs.org)\n[![Npm Version](https://img.shields.io/npm/v/@theprodev/distributed-lock?style=for-the-badge)](https://www.npmjs.com/package/@theprodev/distributed-lock)\n[![Weekly Downloads](https://img.shields.io/npm/dw/@theprodev/distributed-lock?style=for-the-badge)](https://www.npmjs.com/package/@theprodev/distributed-lock)\n[![Dependents](https://img.shields.io/librariesio/dependents/npm/@theprodev/distributed-lock?style=for-the-badge)](https://www.npmjs.com/package/@theprodev/distributed-lock)\n[![Minified Zipped Size](https://img.shields.io/bundlephobia/minzip/@theprodev/distributed-lock?style=for-the-badge)](https://www.npmjs.com/package/@theprodev/distributed-lock)\n[![Code Coverage](https://img.shields.io/codecov/c/github/0xtheprodev/distributed-lock?style=for-the-badge\u0026token=Y2LTY0MA2U)](https://codecov.io/github/0xTheProDev/distributed-lock)\n[![Types](https://img.shields.io/npm/types/@theprodev/distributed-lock?style=for-the-badge)](https://www.npmjs.com/package/@theprodev/distributed-lock)\n[![License](https://img.shields.io/github/license/0xTheProDev/distributed-lock?style=for-the-badge\u0026label=license)](https://github.com/0xTheProDev/distributed-lock/blob/main/LICENSE)\n[![Open Issues](https://img.shields.io/github/issues-raw/0xTheProDev/distributed-lock?style=for-the-badge)](https://github.com/0xTheProDev/distributed-lock/issues)\n[![Closed Issues](https://img.shields.io/github/issues-closed-raw/0xTheProDev/distributed-lock?style=for-the-badge)](https://github.com/0xTheProDev/distributed-lock/issues?q=is%3Aissue+is%3Aclosed)\n[![Open Pulls](https://img.shields.io/github/issues-pr-raw/0xTheProDev/distributed-lock?style=for-the-badge)](https://github.com/0xTheProDev/distributed-lock/pulls)\n[![Closed Pulls](https://img.shields.io/github/issues-pr-closed-raw/0xTheProDev/distributed-lock?style=for-the-badge)](https://github.com/0xTheProDev/distributed-lock/pulls?q=is%3Apr+is%3Aclosed)\n[![Contributors](https://img.shields.io/github/contributors/0xTheProDev/distributed-lock?style=for-the-badge)](https://github.com/0xTheProDev/distributed-lock/graphs/contributors)\n[![Activity](https://img.shields.io/github/last-commit/0xTheProDev/distributed-lock?style=for-the-badge\u0026label=most%20recent%20activity)](https://github.com/0xTheProDev/distributed-lock/pulse)\n\n## Description\n\n\u003e A Distributed Locking Mechanism implemented using Redis to provide Mutual Exclusion over Shared Resources in a Microservices Architecture.\n\nIn modern digital systems, we are often working with Distributed Workloads, Horizontal Scaling and Microservices. These systems do not share the same memory spaces or sometimes even the same host machine. Because of which traditional Mutex and Semaphore does not adapt with the current requirements to acquire exclusive access to shared resources. This library aims to bridge that gap using a common Remote Dictionary Server (Redis) with special attention to easy to integrate APIs and performance.\n\n[Read More](https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html).\n\n## Installation\n\nInstall this package using your preferred package manager. See the example of [yarn](https://yarnpkg.com):\n\n```sh\nyarn add @theprodev/distributed-lock\n```\n\n## Usage\n\nMost common usage entails executing a block of code (asynchronous functions are supported) within a Mutual Exclusion region which ensures that no other code is being executed on the same resources.\n\n```ts\nimport DistributedLock from \"@theprodev/distributed-lock\";\n\nconst distributedLock = new DistributedLock({\n  host: \"redis://example.com\",\n  port: 6379,\n});\n\nasync function runExclusively() {\n  return await distributedLock.execute(\"fetch\", async () =\u003e\n    fetch(\"https://http.cat/200\"),\n  );\n}\n```\n\nFor any further usage, refer to the [Type Declaration](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html) shipped with the package. Make sure your editor or IDE is capable of powering intellisense from the declaration file provided.\n\n## Testing\n\n- To run all the unit test suites, run the following after all the dependencies have been installed:\n\n```sh\nyarn test\n```\n\n- To collect coverage on the tested files, execute the following command:\n\n```sh\nyarn test:cov\n```\n\n## Reporting a Bug\n\nHead on to [**Discussion**](https://github.com/0xTheProDev/distributed-lock/discussions) section to report a bug or to ask for any feature. Feel to add your queries about using this library as well under _Q \u0026 A_ section of it. Remember, do not create any Issues by yourself, maintainers of this repository will open one if deemed necessary.\n\n## Changelog\n\nSee [CHANGELOG](https://github.com/0xTheProDev/distributed-lock/blob/main/CHANGELOG.md) for more details on what has been changed in the latest release.\n\n## Contributing\n\nSee [Contributing Guidelines](https://github.com/0xTheProDev/distributed-lock/blob/main/.github/CONTRIBUTING.md).\n\n## License\n\nThis project is licensed under the terms of the MIT license, see [LICENSE](https://github.com/0xTheProDev/distributed-lock/blob/main/LICENSE) for more details.\n\n\u003ca href=\"https://github.com/0xTheProDev\"\u003e\n  \u003cimg src=\".github/assets/the-pro-dev-original.png\" alt=\"The Pro Dev\" height=\"120\" width=\"120\"/\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xtheprodev%2Fdistributed-lock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xtheprodev%2Fdistributed-lock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xtheprodev%2Fdistributed-lock/lists"}