TypeScript API / laikacms/locks/in-process / InProcessLockManager
Class: InProcessLockManager
Advisory lock manager held entirely in one process's memory (ADR-007).
Every read-modify-write runs inside Effect.tx, so acquire is genuinely atomic: two fibers racing for a free lock cannot both win, which is the bug the previous read-check-write LockStore design could not avoid.
That atomicity stops at the process boundary. Two nodes each get their own map and each believes it holds the lock, which is exactly why the capability this advertises is scope: 'in-process' and never 'shared'. Use it for single-node deployments and tests; a multi-node deployment needs a backend whose datasource has a real conditional write.
transactional: false: it brackets a lock around work, it does not roll the work back.
Constructors
Constructor
new InProcessLockManager(options?): InProcessLockManager;Parameters
| Parameter | Type |
|---|---|
options | InProcessLockManagerOptions |
Returns
InProcessLockManager
Properties
capability
readonly static capability: object;The capability this manager backs. Repositories delegating here must report exactly this.
description
readonly description: string;scope
readonly scope: "in-process" = 'in-process';supported
readonly supported: true = true;transactional
readonly transactional: false = false;Methods
acquireLock()
acquireLock(
key,
owner,
options?
): LaikaTask<{
acquiredAt: Utc;
expiresAt: Utc;
key: string;
owner: {
id: string;
name: string;
};
token: string & Brand<"LockToken">;
}>;Parameters
| Parameter | Type |
|---|---|
key | string |
owner | { id: string; name: string; } |
owner.id | string |
owner.name? | string |
options? | { force?: boolean; ttlMs?: number; } |
options.force? | boolean |
options.ttlMs? | number |
Returns
LaikaTask<{ acquiredAt: Utc; expiresAt: Utc; key: string; owner: { id: string; name: string; }; token: string & Brand<"LockToken">; }>
getLock()
getLock(key): LaikaTask<
| {
acquiredAt: Utc;
expiresAt: Utc;
key: string;
owner: {
id: string;
name: string;
};
}
| null>;Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
LaikaTask< | { acquiredAt: Utc; expiresAt: Utc; key: string; owner: { id: string; name: string; }; } | null>
refreshLock()
refreshLock(
key,
token,
owner,
options?
): LaikaTask<{
acquiredAt: Utc;
expiresAt: Utc;
key: string;
owner: {
id: string;
name: string;
};
token: string & Brand<"LockToken">;
}>;Parameters
| Parameter | Type |
|---|---|
key | string |
token | string & Brand<"LockToken"> |
owner | { id: string; name: string; } |
owner.id | string |
owner.name? | string |
options? | { ttlMs?: number; } |
options.ttlMs? | number |
Returns
LaikaTask<{ acquiredAt: Utc; expiresAt: Utc; key: string; owner: { id: string; name: string; }; token: string & Brand<"LockToken">; }>
releaseLock()
releaseLock(key, token): LaikaTask<void>;Parameters
| Parameter | Type |
|---|---|
key | string |
token | string & Brand<"LockToken"> |
Returns
LaikaTask<void>