Class InMemoryEventStore
java.lang.Object
io.fluxzero.sdk.tracking.client.InMemoryMessageStore
io.fluxzero.sdk.persisting.eventsourcing.client.InMemoryEventStore
- All Implemented Interfaces:
Monitored<List<SerializedMessage>>, HasMessageStore, MessageStore, EventStoreClient, AutoCloseable
An implementation of the
EventStoreClient interface that provides an in-memory event storage solution. This
class extends InMemoryMessageStore to inherit message store functionality and provides additional
capabilities for storing, retrieving, updating, and managing aggregate event streams and relationships in memory.
It is designed for use cases where events and relationships are stored and maintained in the application memory, which makes it lightweight but volatile. The stored data will not persist beyond the lifetime of the application process and is typically used in test scenarios or for development purposes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeleteEvents(String aggregateId, Guarantee guarantee) Deletes all events for a specific aggregate with a given delivery guarantee.getAggregateIds(GetAggregateIds request) Gets aggregate IDs based on aGetAggregateIdsrequest.Retrieves the event stream for an aggregate with control over size and offset.getRelationships(GetRelationships request) Gets relationships based on aGetRelationshipsrequest.repairRelationships(RepairRelationships request) Repairs entity relationships, e.g. by forcing re-evaluation of existing relationships.storeEvents(String aggregateId, List<SerializedMessage> events, boolean storeOnly, Guarantee guarantee) Stores events for a given aggregate with an explicit guarantee.toString()updateRelationships(UpdateRelationships request) Updates entity relationships in the event store (e.g. parent-child, references).Methods inherited from class InMemoryMessageStore
append, close, filterMessages, getBatch, getMessage, notifyMonitors, notifyMonitors, purgeExpiredMessages, registerMonitorMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface EventStoreClient
close, deleteEvents, getAggregatesFor, getEvents, getEvents, getRelationships, storeEventsMethods inherited from interface MessageStore
append, getBatch, getMessageStore, setRetentionTime, unwrap
-
Constructor Details
-
InMemoryEventStore
public InMemoryEventStore() -
InMemoryEventStore
-
-
Method Details
-
storeEvents
public CompletableFuture<Void> storeEvents(String aggregateId, List<SerializedMessage> events, boolean storeOnly, Guarantee guarantee) Description copied from interface:EventStoreClientStores events for a given aggregate with an explicit guarantee.- Specified by:
storeEventsin interfaceEventStoreClient- Parameters:
aggregateId- The aggregate ID.events- Events to store.storeOnly- Iftrue, events will not be published.guarantee- The guarantee level for this operation.- Returns:
- A future representing completion of the store operation.
-
updateRelationships
Description copied from interface:EventStoreClientUpdates entity relationships in the event store (e.g. parent-child, references).- Specified by:
updateRelationshipsin interfaceEventStoreClient- Parameters:
request- The update request.- Returns:
- A future that completes when the operation is acknowledged.
-
repairRelationships
Description copied from interface:EventStoreClientRepairs entity relationships, e.g. by forcing re-evaluation of existing relationships.- Specified by:
repairRelationshipsin interfaceEventStoreClient- Parameters:
request- The repair request.- Returns:
- A future that completes when the repair is done.
-
getEvents
public AggregateEventStream<SerializedMessage> getEvents(String aggregateId, long lastSequenceNumber, int maxSize) Description copied from interface:EventStoreClientRetrieves the event stream for an aggregate with control over size and offset.- Specified by:
getEventsin interfaceEventStoreClient- Parameters:
aggregateId- The aggregate ID.lastSequenceNumber- Sequence number to resume after.maxSize- Maximum number of events to return (or -1 for unlimited).- Returns:
- A stream of serialized events.
-
deleteEvents
Description copied from interface:EventStoreClientDeletes all events for a specific aggregate with a given delivery guarantee.- Specified by:
deleteEventsin interfaceEventStoreClient- Parameters:
aggregateId- The aggregate ID.guarantee- The guarantee to apply.- Returns:
- A future that completes when deletion is acknowledged.
-
getAggregateIds
Description copied from interface:EventStoreClientGets aggregate IDs based on aGetAggregateIdsrequest.- Specified by:
getAggregateIdsin interfaceEventStoreClient- Parameters:
request- The request containing filtering options.- Returns:
- A map of aggregate IDs referencing the target entity.
-
getRelationships
Description copied from interface:EventStoreClientGets relationships based on aGetRelationshipsrequest.- Specified by:
getRelationshipsin interfaceEventStoreClient- Parameters:
request- The request containing filter parameters.- Returns:
- A list of matching relationships.
-
toString
- Overrides:
toStringin classInMemoryMessageStore
-