Skip to main content
Version: Current

Lease

@rotorsoft/act-root


@rotorsoft/act-root / act/src / Lease

Type Alias: Lease

Lease = object

Defined in: libs/act/src/types/reaction.ts:359

Lease information for distributed stream processing.

Leases prevent concurrent processing of the same stream by multiple workers. When a worker acquires a lease, it has exclusive rights to process events for that stream until the lease expires or is acknowledged.

The drain process uses leases to:

  • Prevent race conditions in distributed setups
  • Track processing progress (watermark)
  • Manage retries on failures
  • Balance load between lagging and leading streams

Exampleโ€‹

app.on("acked", (leases) => {
leases.forEach(lease => {
console.log(`Processed ${lease.stream} up to event ${lease.at}`);
});
});

app.on("blocked", (blocked) => {
blocked.forEach(({ stream, retry, error }) => {
console.error(`Stream ${stream} blocked after ${retry} retries: ${error}`);
});
});

Seeโ€‹

Drain for drain cycle results

Propertiesโ€‹

atโ€‹

readonly at: number

Defined in: libs/act/src/types/reaction.ts:362

Watermark: last successfully processed event ID


byโ€‹

readonly by: string

Defined in: libs/act/src/types/reaction.ts:363

Unique identifier of the lease holder (UUID)


due?โ€‹

readonly optional due?: number

Defined in: libs/act/src/types/reaction.ts:379

Defer marker on the finalize path. When set on a lease passed to Store.ack, the entry is deferred alongside its watermark advance: the adapter advances the watermark to at (the last event handled this cycle) and persists due (ms since epoch) as the stream's deferred_at, setting retry to the entry's own value โ€” atomically with the other entries' acks. Advance and defer are independent legs, so a partial-progress defer keeps the handled prefix (it never re-runs on redelivery) while the remainder waits for due. Deferred entries are not part of ack's return value. Never set on leases returned by claim or carried by lifecycle events.


laggingโ€‹

readonly lagging: boolean

Defined in: libs/act/src/types/reaction.ts:365

Whether this stream is behind (lagging frontier)


lane?โ€‹

readonly optional lane?: string

Defined in: libs/act/src/types/reaction.ts:366

Drain lane the stream is bound to


retryโ€‹

readonly retry: number

Defined in: libs/act/src/types/reaction.ts:364

Number of retry attempts (0 = first attempt)


source?โ€‹

readonly optional source?: string

Defined in: libs/act/src/types/reaction.ts:361

Optional source the subscription consumes from (literal name or regex pattern)


streamโ€‹

readonly stream: string

Defined in: libs/act/src/types/reaction.ts:360

The target stream name being processed