Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@0xtheprodev/distributed-lock

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0xtheprodev/distributed-lock

A Distributed Locking Mechanism implemented over Redis to provide Mutex in a Microservices Architecture

  • 1.1.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

Distributed Lock

Distributed Lock Icon


Regression Release

Sponsor Node LTS Npm Version Weekly Downloads Dependents Minified Zipped Size Code Coverage Types License Open Issues Closed Issues Open Pulls Closed Pulls Contributors Activity

Description

A Distributed Locking Mechanism implemented using Redis to provide Mutual Exclusion over Shared Resources in a Microservices Architecture.

In 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.

Read More.

Installation

Install this package using your preferred package manager. See the example of yarn:

yarn add @0xtheprodev/distributed-lock

Usage

Most 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.

import DistributedLock from "@0xtheprodev/distributed-lock";

const distributedLock = new DistributedLock({
  host: "redis://example.com",
  port: 6379,
});

async function runExclusively() {
  return await distributedLock.execute("fetch", async () =>
    fetch("https://http.cat/200"),
  );
}

For any further usage, refer to the Type Declaration shipped with the package. Make sure your editor or IDE is capable of powering intellisense from the declaration file provided.

Testing

  • To run all the unit test suites, run the following after all the dependencies have been installed:
yarn test
  • To collect coverage on the tested files, execute the following command:
yarn test:cov

Reporting a Bug

Head on to Discussion section to report a bug or to ask for any feature. Feel to add your queries about using this library as well under Q & A section of it. Remember, do not create any Issues by yourself, maintainers of this repository will open one if deemed necessary.

Changelog

See CHANGELOG for more details on what has been changed in the latest release.

Contributing

See Contributing Guidelines.

License

This project is licensed under the terms of the MIT license, see LICENSE for more details.

Keywords

FAQs

Package last updated on 22 Jul 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc