Class DefaultEventStore
java.lang.Object
io.fluxzero.sdk.persisting.eventsourcing.DefaultEventStore
- All Implemented Interfaces:
Namespaced<EventStore>, EventStore, HasLocalHandlers
Default implementation of the
EventStore interface, providing mechanisms to store and retrieve events
associated with aggregate instances.
This implementation includes support for intercepting and modifying event messages during dispatch. The
HandlerRegistry is used to locally invoke event handlers after events are published.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionforNamespace(String namespace) Creates and returns the resource scoped to the specified namespace.Retrieves the event stream for an aggregate with full control over behavior.storeEvents(Object aggregateId, List<?> events, EventPublicationStrategy strategy) Stores a list of events for the given aggregate using a specified publication strategy.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EventStore
getEvents, getEvents, getEvents, storeEvents, storeEventsMethods inherited from interface HasLocalHandlers
hasLocalHandlers, registerHandler, registerHandler, setSelfHandlerFilterMethods inherited from interface Namespaced
forDefaultNamespace
-
Constructor Details
-
DefaultEventStore
public DefaultEventStore()
-
-
Method Details
-
storeEvents
public CompletableFuture<Void> storeEvents(Object aggregateId, List<?> events, EventPublicationStrategy strategy) Description copied from interface:EventStoreStores a list of events for the given aggregate using a specified publication strategy.- Specified by:
storeEventsin interfaceEventStore- Parameters:
aggregateId- The ID of the aggregate.events- The events to store.strategy- Whether to publish the events in addition to storing them.- Returns:
- A future that completes once the operation is acknowledged.
-
getEvents
public AggregateEventStream<DeserializingMessage> getEvents(Object aggregateId, long lastSequenceNumber, int maxSize, boolean ignoreUnknownType) Description copied from interface:EventStoreRetrieves the event stream for an aggregate with full control over behavior.- Specified by:
getEventsin interfaceEventStore- Parameters:
aggregateId- The ID of the aggregate.lastSequenceNumber- The last known sequence number to resume from.maxSize- The maximum number of events to return.ignoreUnknownType- Whether to ignore unknown payload types when deserializing events.- Returns:
- A stream of deserialized messages representing the event history of the aggregate.
-
forNamespace
Description copied from interface:NamespacedCreates and returns the resource scoped to the specified namespace.- Specified by:
forNamespacein interfaceNamespaced<EventStore>- Parameters:
namespace- the namespace to which the returned resource is scoped- Returns:
- the resource associated with the specified namespace
-