connect()
connect() constructs Pulse immediately and creates one background readiness promise. Use awaitConnection() during application startup to surface connection, permission, and index errors before accepting traffic.
Connection options
Strings must be non-empty.
maxPoolSize must be a positive integer. Durations and worker counts must be finite positive numbers, except retention, retry counts, retry delays, and maxIdleTimeMS may be zero where their types allow it. Retry settings are rejected when their largest computed delay falls outside MongoDB’s supported date range.
Pulse sets the MongoDB driver’s maxPoolSize to 1 instead of its default of 100, explicitly keeps
minPoolSize at 0, and closes application connections after 30 idle seconds. The pool socket is
used only for short coordination operations; callbacks do not retain it and can still run
concurrently. The limit applies to application connections in each server pool. The driver also
opens topology-monitoring connections that are not counted by maxPoolSize.
pulse.awaitConnection()
publish(), subscribe(), and subscribeBatch() call it internally.
pulse.publish()
_id is a UUIDv7 string. Pulse never uses MongoDB ObjectId for its own documents.
pulse.subscribe()
Subscription options
The handler can return
void or Promise<void>:
PulseReceivedEvent contains every published event field plus consumerGroup and the one-based attempt number.
The returned subscription contains the resolved options, including the winning configVersion,
and an idempotent asynchronous unsubscribe() method.
pulse.subscribeBatch()
void or Promise<void>:
batchSize, a positive integer with no
library-defined maximum. The configured size is a maximum. Pulse immediately executes a partial
batch when fewer events are available; it does not add a batching timer.
One array invocation consumes one worker and one maxConcurrency slot. Retry, fencing, heartbeat,
and acknowledgement apply to the complete array. Batch materialization atomically inserts the
delivery and advances its discovery cursor in a MongoDB transaction, so this API requires a replica
set, sharded cluster, or Atlas.
pulse.getSubscriptions()
pulse.close()
Exported errors
Collections
The names usecollectionPrefix, which defaults to orionjs.pulse:
Every Pulse-created
_id, lock owner, and fencing token is a UUIDv7 string.