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:348

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:351

Watermark: last successfully processed event ID


byโ€‹

readonly by: string

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

Unique identifier of the lease holder (UUID)


due?โ€‹

readonly optional due?: number

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

Defer marker on the finalize path. When set on a lease passed to Store.ack, the stream is being deferred, not acked: the adapter must persist due (ms since epoch) as the stream's deferred_at and reset retry โ€” without advancing the watermark โ€” atomically with the other entries' acks. 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:354

Whether this stream is behind (lagging frontier)


lane?โ€‹

readonly optional lane?: string

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

Drain lane the stream is bound to (ACT-1103)


retryโ€‹

readonly retry: number

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

Number of retry attempts (0 = first attempt)


source?โ€‹

readonly optional source?: string

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

Optional exact source stream name the subscription consumes from


streamโ€‹

readonly stream: string

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

The target stream name being processed