Skip to main content

Lease

@rotorsoft/act-root


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

Type Alias: Lease

Lease = object

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

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

Watermark: last successfully processed event ID


byโ€‹

readonly by: string

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

Unique identifier of the lease holder (UUID)


laggingโ€‹

readonly lagging: boolean

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

Whether this stream is behind (lagging frontier)


lane?โ€‹

readonly optional lane?: string

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

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


retryโ€‹

readonly retry: number

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

Number of retry attempts (0 = first attempt)


source?โ€‹

readonly optional source?: string

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

Optional source stream for filtering


streamโ€‹

readonly stream: string

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

The target stream name being processed