Lease
@rotorsoft/act-root / act/src / Lease
Type Alias: Lease
Lease =
object
Defined in: libs/act/src/types/reaction.ts:326
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
readonlyat:number
Defined in: libs/act/src/types/reaction.ts:329
Watermark: last successfully processed event ID
by
readonlyby:string
Defined in: libs/act/src/types/reaction.ts:330
Unique identifier of the lease holder (UUID)
due?
readonlyoptionaldue?:number
Defined in: libs/act/src/types/reaction.ts:346
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
readonlylagging:boolean
Defined in: libs/act/src/types/reaction.ts:332
Whether this stream is behind (lagging frontier)
lane?
readonlyoptionallane?:string
Defined in: libs/act/src/types/reaction.ts:333
Drain lane the stream is bound to
retry
readonlyretry:number
Defined in: libs/act/src/types/reaction.ts:331
Number of retry attempts (0 = first attempt)
source?
readonlyoptionalsource?:string
Defined in: libs/act/src/types/reaction.ts:328
Optional source the subscription consumes from (literal name or regex pattern)
stream
readonlystream:string
Defined in: libs/act/src/types/reaction.ts:327
The target stream name being processed