Skip to content

Added Persistent Queries

Compare
Choose a tag to compare
@ncthbrt ncthbrt released this 18 May 22:36
· 106 commits to master since this release
17a10cf

This new feature is especially for architectures which may require a CQRS approach.

A persistentQuery is similar to an actor, except it cannot cannot persist messages, does not have context and checks the event store each time it is invoked for messages it has not yet processed (later versions may may use of streaming). Additionally a persistent query supports snapshotting of state, making it ideal as an event model.

Usage is below, however a more detailed tutorial is to follow on nact.io once the reason version is published:

let query = persistentQuery(
      system,
      (result, msg) => apply(result,msg),
      'persistenceKey',
      { cacheDuration: 10 *minutes, snapshotKey: 'test', snapshotEvery: 5 * messages }
);
let result = await query();