---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/orchestration/interfaces/PlanLockFactory.md
description: Creates and restores `PlanLock` instances for a deployment.
---

# Interface: PlanLockFactory

Defined in: [src/batteries/orchestration/locks.ts:140](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/locks.ts#L140)

Creates and restores `PlanLock` instances for a deployment.

A BYO seam: a consumer can satisfy it with Verrou directly (memory / Redis / Postgres drivers)
or with anything else; the battery adds no dependency. Supplying a factory makes concurrent
execution UNLIKELY rather than impossible — it does not fence, and a partitioned holder can
still double-invoke a node (see the module docs).

## Methods

### createLock()

```ts
createLock(key: string, ttl?: string | number): PlanLock;
```

Defined in: [src/batteries/orchestration/locks.ts:145](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/locks.ts#L145)

Create a new lease for `key`, with an optional TTL (a number of milliseconds or a duration
string). The lease is not acquired until `acquire`/`acquireImmediately`/`run` is called.

#### Parameters

| Parameter | Type                 |
| --------- | -------------------- |
| `key`     | `string`             |
| `ttl?`    | `string` | `number` |

#### Returns

[`PlanLock`](PlanLock.md)

***

### restoreLock()

```ts
restoreLock(serialized: string): PlanLock;
```

Defined in: [src/batteries/orchestration/locks.ts:154](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/locks.ts#L154)

Rehydrate a lease from a string produced by `PlanLock.serialize`.

Exists so a lease can be handed from the process that started a run to the one resuming it,
letting the resuming process continue holding the same lease rather than racing to re-acquire
it. The restored lock must behave as the original for the remainder of its TTL.

#### Parameters

| Parameter    | Type     |
| ------------ | -------- |
| `serialized` | `string` |

#### Returns

[`PlanLock`](PlanLock.md)
