Interface SourcingHandler<I,E>

Type Parameters:
I - the type of the entity identifier
E - the type of the entity
All Superinterfaces:
DescribableComponent
All Known Implementing Classes:
SimpleSourcingHandler, SnapshottingSourcingHandler

@Internal public interface SourcingHandler<I,E> extends DescribableComponent
Handles the sourcing of an entity from its historical event stream.

Implementations of this interface are responsible for retrieving all relevant events for a given identifier and applying them to construct or evolve the entity to its current state.

Since:
5.1.0
Author:
John Hendrikx
  • Method Details

    • source

      CompletableFuture<E> source(I identifier, InitializingEntityEvolver<I,E> evolver, ProcessingContext processingContext)
      Sources the entity identified by the given identifier.

      The InitializingEntityEvolver is used to either create the entity (if it does not exist) or evolve it through the events retrieved from the underlying event stream.

      This method returns a CompletableFuture that completes when the entity has been fully reconstructed or evolved to its latest state.

      Parameters:
      identifier - the identifier of the entity to source, cannot be null
      evolver - the InitializingEntityEvolver used to initialize and evolve the entity, cannot be null
      processingContext - the ProcessingContext associated with this sourcing operation, cannot be null
      Returns:
      a CompletableFuture that completes with the sourced entity, never null