rename promise-retry to retry

This commit is contained in:
Girish Ramakrishnan
2026-03-27 11:39:38 +01:00
parent b08e3a5128
commit 9c3c8cc9d1
15 changed files with 45 additions and 45 deletions

View File

@@ -2,7 +2,7 @@ import assert from 'node:assert';
import BoxError from './boxerror.js';
import database from './database.js';
import logger from './logger.js';
import promiseRetry from './promise-retry.js';
import retry from './retry.js';
const { log } = logger('locks');
@@ -59,7 +59,7 @@ function canAcquire(data, type) {
async function acquire(type) {
assert.strictEqual(typeof type, 'string');
await promiseRetry({ times: Number.MAX_SAFE_INTEGER, interval: 100, log, retry: (error) => error.reason === BoxError.CONFLICT }, async () => {
await retry({ times: Number.MAX_SAFE_INTEGER, interval: 100, log, retry: (error) => error.reason === BoxError.CONFLICT }, async () => {
const { version, data } = await read();
const error = canAcquire(data, type);
if (error) throw error;
@@ -72,13 +72,13 @@ async function acquire(type) {
async function wait(type) {
assert.strictEqual(typeof type, 'string');
await promiseRetry({ times: Number.MAX_SAFE_INTEGER, interval: 10000, log }, async () => await acquire(type));
await retry({ times: Number.MAX_SAFE_INTEGER, interval: 10000, log }, async () => await acquire(type));
}
async function release(type) {
assert.strictEqual(typeof type, 'string');
await promiseRetry({ times: Number.MAX_SAFE_INTEGER, interval: 100, log, retry: (error) => error.reason === BoxError.CONFLICT }, async () => {
await retry({ times: Number.MAX_SAFE_INTEGER, interval: 100, log, retry: (error) => error.reason === BoxError.CONFLICT }, async () => {
const { version, data } = await read();
if (!(type in data)) throw new BoxError(BoxError.BAD_STATE, `Lock ${type} was never acquired`);
if (data[type] !== gTaskId) throw new BoxError(BoxError.BAD_STATE, `Task ${gTaskId} attempted to release lock ${type} acquired by ${data[type]}`);
@@ -98,7 +98,7 @@ async function releaseAll() {
async function releaseByTaskId(taskId) {
assert.strictEqual(typeof taskId, 'string');
await promiseRetry({ times: Number.MAX_SAFE_INTEGER, interval: 100, log, retry: (error) => error.reason === BoxError.CONFLICT }, async () => {
await retry({ times: Number.MAX_SAFE_INTEGER, interval: 100, log, retry: (error) => error.reason === BoxError.CONFLICT }, async () => {
const { version, data } = await read();
for (const type of Object.keys(data)) {