SnapshotSubscription
The built-in wow.snapshot subscription of one bounded context: keeps the latest snapshot of every aggregate of the models given, the aggregate types whose snapshots are enabled. Register subscription in the context's me.ahoo.wow.runtime.subscription.SubscriptionRuntime and give views to the me.ahoo.wow.runtime.Executor: it then runs on each partition's owner, checkpoints, parks and signals like any subscription, and completes the default wait, snapshot (handled(wow.snapshot)). An aggregate type not among models has no snapshot, and its default wait is committed.
Merged writes: of an aggregate's entries waiting together, only the latest is written; the waits on the earlier ones complete with it (Subscription.coalesces).
Batched writes: the snapshots built while a write runs are written together, with one SnapshotStore.saveAll of at most writeBatch (SnapshotWrites), one commit on a transactional store. The partitions share WRITE_LANES writers: one per partition left most writes with a single snapshot, one for all of them could not keep up with a node's commits; each entry's handling, and so its wait signal and checkpoint, ends only once the write that covers it is durable, and a snapshot the store fails parks only its own aggregate.
The state: read as every state consumer of the context reads it (EntryDecoder.stateEvents), as the reader Hop.SNAPSHOT_SUBSCRIPTION of the context's shared views: the view taken when the stream committed on this node; without one (a replay, an ownership change, a command run on another node) the stored snapshot or a nearer view evolved with the log's tail up to the stream (Kernel.stateAt), else the log replayed.
The record: built by EventCodec.snapshotOf; its scope is the stream's, its deleted mark and schedules the kernel's after the stream, its last event time and operator the stream's, its first event time and first operator those of the aggregate's first stream. The kernel reloads a deleted aggregate from it as such.
Idempotent: SnapshotStore.save only ever replaces a lower version, so a replay or an old owner running alongside the new one never moves a snapshot back. When the store already holds the stream's version or a later one, as this subscription last wrote or loaded it, nothing is rebuilt or saved, from a view or without one, and the subscription passes the aggregate's views up to that version: a view recorded after its entry was written without it never costs a second write.
Snapshot targets: the subscription writes one store, the target it is named after (SnapshotTargets.subscriptionOf); a context with several targets runs one per store, each with its own checkpoints. A wait's
snapshothop of an aggregate is answered by the subscription of its type's primary target (answers); a subscription that backfills a target stops writing a type once it is no longer active for it.State revisions: the snapshot carries the model's state revision; the store never lets it replace one of a higher revision, and marks that one stale instead, for the rebuild.
codec must be the kernel's, so the views and the fingerprints are what the kernel reads back. views are the context's, where this subscription is the reader name of the snapshotted types; by default its own, bounded by capacity. capacity also bounds the versions, first event times and first operators kept per aggregate.
Constructors
Properties
The subscription to register: named, of the snapshotted aggregate types only.
The shared states the executor records for the snapshotted aggregate types, this subscription one of their readers.