Interface Snapshotter<I,E>

Type Parameters:
I - the type of the entity identifier
E - the type of the entity being snapshotted
All Known Implementing Classes:
StoreBackedSnapshotter

@Internal public interface Snapshotter<I,E>
A Snapshotter is responsible for loading and storing snapshots of event-sourced entities.
Since:
5.1.0
Author:
John Hendrikx
  • Method Summary

    Modifier and Type
    Method
    Description
    load(I identifier)
    Asynchronously retrieves the snapshot for the given identifier, if one exists.
    void
    store(I identifier, E entity, Position position)
    Stores the given entity as a snapshot asynchronously.
  • Method Details

    • load

      CompletableFuture<Snapshot> load(I identifier)
      Asynchronously retrieves the snapshot for the given identifier, if one exists.

      The returned CompletableFuture completes with the snapshot, or null if none exists or the snapshot cannot be used. It may complete exceptionally if snapshot retrieval fails.

      Parameters:
      identifier - the identifier of the entity, cannot be null
      Returns:
      a CompletableFuture that completes with the entity's snapshot or null
      Throws:
      NullPointerException - if identifier is null
    • store

      void store(I identifier, E entity, Position position)
      Stores the given entity as a snapshot asynchronously.
      Parameters:
      identifier - the identifier of the entity, cannot be null
      entity - the entity state, cannot be null
      position - the position in the event stream for this entity state, cannot be null
      Throws:
      NullPointerException - if any argument is null