Lease
@rotorsoft/act-root / act/src / Lease
Type Alias: Lease
Lease =
object
Defined in: libs/act/src/types/reaction.ts:350
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:353
Watermark: last successfully processed event ID
byโ
readonlyby:string
Defined in: libs/act/src/types/reaction.ts:354
Unique identifier of the lease holder (UUID)
due?โ
readonlyoptionaldue?:number
Defined in: libs/act/src/types/reaction.ts:370
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
(#1278). 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:356
Whether this stream is behind (lagging frontier)
lane?โ
readonlyoptionallane?:string
Defined in: libs/act/src/types/reaction.ts:357
Drain lane the stream is bound to (ACT-1103)
retryโ
readonlyretry:number
Defined in: libs/act/src/types/reaction.ts:355
Number of retry attempts (0 = first attempt)
source?โ
readonlyoptionalsource?:string
Defined in: libs/act/src/types/reaction.ts:352
Optional source the subscription consumes from (literal name or regex pattern)
streamโ
readonlystream:string
Defined in: libs/act/src/types/reaction.ts:351
The target stream name being processed