Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@google-automations/datastore-lock

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-automations/datastore-lock

Distributed lock backed by Google Cloud Datastore

latest
Source
npmnpm
Version
7.1.3
Version published
Weekly downloads
2.5K
25.76%
Maintainers
1
Weekly downloads
 
Created
Source

A distributed lock

This is a simple lock library backed by Google Cloud Datastore.

Github bots can have multiple instances and sometimes those instances are modifying the same target (issue, pull request, etc). This simple library allows the bot to acquire a lock on sth.

Usage

Install

npm i @google-automations/datastore-lock

Usage

import {DatastoreLock} from '@google-automations/datastore-lock';

// Most of the cases, you can just pass `lockId` and `target`.
// `lockId` is usually the bot name.
// `target` is the target for the lock.

const lockId = 'blunderbuss';
const target = context.payload.pull_request.url;

const lock = new DatastoreLock(lockId, target);
// await lock.peek(); // was there already a lock perhaps?
const result = await lock.acquire();
if (!result) {
	// failure
}
// Do your stuff, and release the lock after you've done.
result = await lock.release();
// The lock will become stale after 20 seconds.
// You can pass the 3rd argument for longer expiry, up to 60 seconds.
const lock2 = new DatastoreLock(lockId, target, 60 * 1000);

Keywords

google cloud datastore

FAQs

Package last updated on 01 Apr 2026

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