@tslock/arangodb
v2.0.1
Published
TSLock provider for ArangoDB using stream transactions
Downloads
226
Readme
@tslock/arangodb
TSLock provider backed by ArangoDB.
A TSLock provider that implements LockProvider directly over the arangojs client. Locks are stored as documents in a collection and updated with optimistic concurrency via _rev.
Installation
pnpm add @tslock/core @tslock/arangodb arangojsUsage
import { createLockConfig, DefaultLockingTaskExecutor } from '@tslock/core';
import { createArangoDbLockProvider } from '@tslock/arangodb';
import { Database } from 'arangojs';
const db = new Database({ url: 'http://localhost:8529', auth: { username: 'root', password: '' } });
const provider = createArangoDbLockProvider(db);
const executor = new DefaultLockingTaskExecutor(provider);
await executor.executeWithLock(
() => myScheduledTask(),
createLockConfig({ name: 'my-task', lockAtMostFor: '5m', lockAtLeastFor: '1m' }),
);Configuration
createArangoDbLockProvider(database, options?) accepts:
| Option | Default | Description |
|---|---|---|
| collection | 'shedLock' | The ArangoDB collection used for lock documents. |
Lock-name safety: Lock names must be non-empty, contain no control characters, and be at most 1024 UTF-8 bytes because the name is stored as the document key.
Requirements
- Node.js >= 22
- Peer:
arangojs
License
Apache 2.0 — see LICENSE for details.
