🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

locksmanager

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

locksmanager

an fully lock api for one-master, one-master-with-multi-cluster.

latest
Source
npmnpm
Version
1.4.3
Version published
Maintainers
1
Created
Source

locks manager

an fully lock api for one-master, one-master-with-multi-cluster.

flow (Single process)

lm = new LocksManager();
 |
lm.appendLock(ids:string[])
 |
(find PER locks by ids. and add ids as CUR locks)
 |
(return locksRef)
 |
await locksRef.getPreJobsDone()
 |
(await Promise.all(PER locks))
 |
...do your jobs
 |
lm.finishAll()
 |
(each CUR locks do unlock. => promise.resolve() )

multi-Progress

there have an default lm in master process. and child process will share this lm.

in master process:

import { registerLocksManagerDefaultValueGetter } from 'locksmanager';
// register an value getter function. and also setup.
// or may be just return undefined. it's ok. save the ipc.
registerLocksManagerDefaultValueGetter(async (lock_id)=>{
    const model = await db.getById(lock_id);
    const {
        ignore_pro_A,
        ignore_pro_B,
        ...filtered_fields
    } = model;
    return filtered_fields;
});

in cluster(worker) process:

import { ClusterLocksManager } from 'locksmanager';
const lm = new ClusterLocksManager();
await lm.appendLock(ids as string[]);
await lm.getPreJobsDone();
// do your jobs
lm.finishAll();

FAQs

Package last updated on 31 Jul 2018

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