ByPidSettings
Defined in: src/persistence/projection/ProjectionActor.ts:59
Actor wrapper around a projection. Owns the polling loop, the offset cursor, and the at-least-once delivery contract:
- preStart — load the cursor from OffsetStore.
- loop — poll the PersistenceQuery for new events from the cursor onwards.
- handle — call the user
handleron each event. The handler MUST be idempotent — see at-least-once below. - commit — save the cursor to the offset store.
- repeat.
At-least-once. If the projection crashes between step 3 and step 4, the next start replays from the saved cursor and the just-handled event will be re-handled. Handlers must therefore either:
- be idempotent (e.g. UPSERT into the read model);
- or do their own dedup via some unique key on the event.
Two query shapes are supported via the static factories:
ProjectionActor.byPersistenceId(...)— one cursor per pid. Use this for “give me everything an entity ever did”. The cursor is the entity’ssequenceNr.ProjectionActor.byTag(...)— one cursor per tag. Use this for “give me every event labelled X across the whole journal”. The cursor is anOffset(timestamp + tiebreakers).
Stopping: the standard actorRef.stop() triggers postStop
which cancels the polling timer; the in-flight handler call (if
any) is awaited before the actor exits.
Extends
Section titled “Extends”Type Parameters
Section titled “Type Parameters”E
Properties
Section titled “Properties”handle
Section titled “handle”
readonlyhandle: (event) =>void|Promise<void>
Defined in: src/persistence/projection/ProjectionActor.ts:54
User handler — runs once per event. Must be idempotent.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void | Promise<void>
Inherited from
Section titled “Inherited from”liveOptions?
Section titled “liveOptions?”
readonlyoptionalliveOptions?:LiveQueryOptions
Defined in: src/persistence/projection/ProjectionActor.ts:56
Tunables passed to the underlying live query.
Inherited from
Section titled “Inherited from”ProjectionSettings.liveOptions
readonlyname:string
Defined in: src/persistence/projection/ProjectionActor.ts:48
Logical name — used as the offset-store key prefix.
Inherited from
Section titled “Inherited from”offsetStore?
Section titled “offsetStore?”
readonlyoptionaloffsetStore?:OffsetStore
Defined in: src/persistence/projection/ProjectionActor.ts:52
Where to persist the cursor. Default: in-memory (lost on restart).
Inherited from
Section titled “Inherited from”ProjectionSettings.offsetStore
persistenceId
Section titled “persistenceId”
readonlypersistenceId:string
Defined in: src/persistence/projection/ProjectionActor.ts:60
readonlyquery:PersistenceQuery
Defined in: src/persistence/projection/ProjectionActor.ts:50
The query layer (one of InMemoryQuery, SqliteQuery, …).