Skip to content

ACT-102: per-event reaction priority lanes #673

@Rotorsoft

Description

@Rotorsoft

Problem

`drain()` processes leases in FIFO order per stream. There's no way to mark a particular reaction as time-sensitive — a slow audit-log reaction can sit in front of a customer-visible "OrderConfirmed → SendEmail" reaction on a busy stream.

Proposed solution

Add a `.priority(n)` modifier on the reaction builder (default 0; higher = sooner):

```ts
slice()
.on("OrderConfirmed")
.do(sendEmail)
.priority(10)
```

`claim()` orders leases by `max(priority across pending events on that stream)` descending, then by stream id for stability.

Acceptance criteria

  • `.priority(n)` available on `slice().on(...)` and the inline `.on(...)` reaction builder on `act()`
  • Default priority is 0; behavior identical to today when no priority is set
  • PG `claim()` uses an index-friendly `ORDER BY priority DESC, at ASC`
  • InMemory adapter respects priority
  • Test: two streams, one with high-priority reaction, both with pending events — high-priority drains first
  • Documented in CLAUDE.md and the slice docs

Out of scope

  • Multiple lanes / dedicated worker pools per priority (consider after we see usage)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions