DefineEventConsumerOptions
Defined in: packages/server/src/events/consumer.ts:223
Type Parameters
Section titled “Type Parameters”TRegistry
Section titled “TRegistry”TRegistry extends SyncTableRegistry
Properties
Section titled “Properties”batchSize?
Section titled “batchSize?”
optionalbatchSize?:number
Defined in: packages/server/src/events/consumer.ts:240
Max messages per read. Defaults to DEFAULT_EVENT_CONSUMER_BATCH_SIZE.
callback
Section titled “callback”callback:
EventConsumerCallback
Defined in: packages/server/src/events/consumer.ts:232
concurrency?
Section titled “concurrency?”
optionalconcurrency?:number
Defined in: packages/server/src/events/consumer.ts:253
Max CONCURRENT callback invocations per Event stream. Defaults to 1 (strictly sequential). Values above 1
are safe for the idempotent callback the lane already requires: ADR-0053 decision 6 disclaims any ordering
across sub-batches precisely so concurrency is available. Reads stay serial — only the callbacks of one
delivered read run in parallel.
maxAttempts?
Section titled “maxAttempts?”
optionalmaxAttempts?:number
Defined in: packages/server/src/events/consumer.ts:258
Deliveries a sub-batch gets before a further callback failure dead-letters it. Defaults to DEFAULT_EVENT_MAX_ATTEMPTS. A malformed body never gets attempts — it dead-letters on sight.
onDeadLetter?
Section titled “onDeadLetter?”
optionalonDeadLetter?: (report) =>void
Defined in: packages/server/src/events/consumer.ts:265
Notified for every dead-lettered sub-batch. The runner ALSO warn-logs each one unconditionally: loudness is the ADR’s requirement and a hook that swallows (or throws) must not be able to make a dead letter silent.
Parameters
Section titled “Parameters”report
Section titled “report”Returns
Section titled “Returns”void
onPoll?
Section titled “onPoll?”
optionalonPoll?: (report) =>void
Defined in: packages/server/src/events/consumer.ts:276
Notified after EVERY read the runner performs — productive or empty, in both pacing modes — which makes it
the host’s liveness heartbeat. The DefineEventConsumerOptions.callback fires only on delivered
batches, so on an idle queue it goes quiet and a liveness/readiness probe answering from it would report a
healthy runner as dead; beat from this instead and treat fault as the queue-health signal.
It fires on the READ, before the batch is delivered, so a slow callback cannot delay the heartbeat. A hook that THROWS can never take a loop down: the throw is caught, warn-logged ONCE per runner (a hook that throws every poll must not drown the log), and the loop carries on.
Parameters
Section titled “Parameters”report
Section titled “report”Returns
Section titled “Returns”void
optionalpoll?:EventConsumerPollOptions
Defined in: packages/server/src/events/consumer.ts:260
Adaptive-poll tuning. See EventConsumerPollOptions.
queue:
EventQueue
Defined in: packages/server/src/events/consumer.ts:231
The queue to consume from — REQUIRED, and the reason the runner is backend-agnostic by construction. The
ordinary wiring is createPgmqEventQueue({ db }) with the app’s own drizzle handle; constructing it here
from a db option would bake the shipped backend into the runner for one line of ergonomics.
registry
Section titled “registry”registry:
TRegistry
Defined in: packages/server/src/events/consumer.ts:225
The sync registry whose streams this runner consumes.
streams?
Section titled “streams?”
optionalstreams?: readonlystring[]
Defined in: packages/server/src/events/consumer.ts:238
Narrow to a subset of the registered Event streams — the knob that splits streams across processes. Defaults to ALL registered streams. An unknown name is a definition-time throw (fail-closed): a runner that silently consumed nothing is the failure mode this forbids.
visibilityTimeoutSeconds?
Section titled “visibilityTimeoutSeconds?”
optionalvisibilityTimeoutSeconds?:number
Defined in: packages/server/src/events/consumer.ts:246
The delivered-message invisibility window, renewed at half of it while the runner is still working through a read. Defaults to DEFAULT_EVENT_VISIBILITY_TIMEOUT_SECONDS. Size it above ONE callback’s worst case (renewal covers the rest of the batch), not above the whole batch’s.