Class InMemoryEventStore
java.lang.Object
io.fluxzero.sdk.tracking.client.InMemoryMessageStore
io.fluxzero.sdk.persisting.eventsourcing.client.InMemoryEventStore
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceApplies direct model documents and due snapshots, returning their local-handler publication for execution after the materialized state and graph-projection fences have advanced.static interfaceWrites current materialized graph documents, returning their local-handler publication for execution after the graph-projection fence has advanced. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondefault CompletableFuture<Void> append(io.fluxzero.common.api.SerializedMessage... arg0) CompletableFuture<io.fluxzero.common.api.modeling.ModelGraphProjectionStatus> awaitModelGraphProjection(io.fluxzero.common.api.modeling.AwaitModelGraphProjection request) Completes after every affected root in a graph projection has crossed the requested committed state boundary.CompletableFuture<io.fluxzero.common.api.modeling.CommitModelsResult> commitModels(io.fluxzero.common.api.modeling.CommitModels commit) Atomically commits the ordered state transitions of one independent-model commit.deleteEvents(String aggregateId, io.fluxzero.common.Guarantee guarantee) Deletes all events for a specific aggregate with a given delivery guarantee.CompletableFuture<io.fluxzero.common.api.modeling.ModelDeletionResult> deleteModel(io.fluxzero.common.api.modeling.DeleteModel request) Executes or resumes an idempotent independent-model hard deletion.getAggregateIds(io.fluxzero.common.api.modeling.GetAggregateIds request) Gets aggregate IDs based on aGetAggregateIdsrequest.default List<io.fluxzero.common.api.SerializedMessage> default List<io.fluxzero.common.api.SerializedMessage> AggregateEventStream<io.fluxzero.common.api.SerializedMessage> Retrieves the event stream for an aggregate with control over size and offset.default io.fluxzero.common.tracking.MessageStoreio.fluxzero.common.api.modeling.GetModelChangeResultgetModelChange(io.fluxzero.common.api.modeling.GetModelChange request) Resolves the durable targets of one model-commit substep.io.fluxzero.common.api.modeling.GetModelEventsResultgetModelEvents(io.fluxzero.common.api.modeling.GetModelEvents request) Batch-loads independent model heads and event memberships at one pinned state boundary.io.fluxzero.common.api.modeling.GetModelGraphResultgetModelGraph(io.fluxzero.common.api.modeling.GetModelGraph request) Loads one bounded temporal model graph and an optional first page of its grouped model streams.io.fluxzero.common.api.modeling.ModelGraphProjectionStatusgetModelGraphProjectionStatus(io.fluxzero.common.api.modeling.GetModelGraphProjectionStatus request) Returns the current high-watermark and backlog for one materialized graph projection.List<io.fluxzero.common.api.modeling.Relationship> getRelationships(io.fluxzero.common.api.modeling.GetRelationships request) Gets relationships based on aGetRelationshipsrequest.protected voidnotifyMonitors(List<io.fluxzero.common.api.SerializedMessage> messages) io.fluxzero.common.api.modeling.ModelDeletionPlanplanModelDeletion(io.fluxzero.common.api.modeling.PlanModelDeletion request) Creates a bounded, non-mutating plan for an explicit independent-model hard deletion.CompletableFuture<io.fluxzero.common.api.modeling.ModelGraphProjectionStatus> registerModelGraphProjection(io.fluxzero.common.api.modeling.RegisterModelGraphProjection request) Idempotently registers an asynchronous materialized model-graph projection.repairRelationships(io.fluxzero.common.api.modeling.RepairRelationships request) Repairs entity relationships, e.g. by forcing re-evaluation of existing relationships.List<io.fluxzero.common.api.modeling.ModelGraphEdge> resolveCurrentGraph(Set<String> rootModelIds, io.fluxzero.common.api.search.ModelGraphComposition composition) Resolves explicitly placed current child edges for one page of root search results.resolveModelDocumentCollections(Set<String> modelIds) Resolves the exact current-document collection for each requested model.resolveRelatedModels(Set<String> relatedModelIds, io.fluxzero.common.api.search.ModelRelationConstraint constraint) Resolves target model IDs from related document matches at the current relationship boundary.default io.fluxzero.common.tracking.MessageStoreBatchscanBatch(Long arg0, int arg1, boolean arg2, long arg3, Predicate<? super io.fluxzero.common.api.SerializedMessage> arg4, boolean arg5) voidLinks the SDK-only event store to the direct in-memory model materializer.voidsetModelGraphProjectionMaterializer(InMemoryEventStore.ModelGraphProjectionMaterializer materializer) Links the SDK-only event store to its in-memory search materializer.voidsetRetentionTime(Duration arg0) storeEvents(String aggregateId, List<io.fluxzero.common.api.SerializedMessage> events, boolean storeOnly, io.fluxzero.common.Guarantee guarantee) Stores events for a given aggregate with an explicit guarantee.toString()CompletableFuture<io.fluxzero.common.api.modeling.TrackModelUpdatesResult> trackModelUpdates(io.fluxzero.common.api.modeling.TrackModelUpdates request) Long-polls committed independent-model commit substeps after a client-controlled state cursor.default <T extends io.fluxzero.common.tracking.MessageStore>
TupdateRelationships(io.fluxzero.common.api.modeling.UpdateRelationships request) Updates entity relationships in the event store (e.g. parent-child, references).Methods inherited from class InMemoryMessageStore
append, appendMessages, close, filterMessages, getBatch, getBatch, getMessage, messagesFrom, monitorNotificationLock, notifyMonitors, purgeExpiredMessages, registerMonitor, scanBatch, truncate, truncateMessagesMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface EventStoreClient
close, deleteEvents, getAggregatesFor, getEvents, getEvents, getRelationships, storeEvents
-
Constructor Details
-
InMemoryEventStore
public InMemoryEventStore() -
InMemoryEventStore
-
-
Method Details
-
setModelGraphProjectionMaterializer
public void setModelGraphProjectionMaterializer(InMemoryEventStore.ModelGraphProjectionMaterializer materializer) Links the SDK-only event store to its in-memory search materializer. -
setModelCommitMaterializer
Links the SDK-only event store to the direct in-memory model materializer. -
storeEvents
public CompletableFuture<Void> storeEvents(String aggregateId, List<io.fluxzero.common.api.SerializedMessage> events, boolean storeOnly, io.fluxzero.common.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.
-
commitModels
public CompletableFuture<io.fluxzero.common.api.modeling.CommitModelsResult> commitModels(io.fluxzero.common.api.modeling.CommitModels commit) Description copied from interface:EventStoreClientAtomically commits the ordered state transitions of one independent-model commit.Unlike aggregate event appends, this operation returns the runtime-assigned state, event, and per-model stream positions. Implementations predating independent models remain source-compatible and fail only when this capability is invoked.
- Specified by:
commitModelsin interfaceEventStoreClient- Parameters:
commit- complete model commit with its durable idempotency key- Returns:
- durable result containing the positions assigned by the event store
-
notifyMonitors
- Overrides:
notifyMonitorsin classInMemoryMessageStore
-
trackModelUpdates
public CompletableFuture<io.fluxzero.common.api.modeling.TrackModelUpdatesResult> trackModelUpdates(io.fluxzero.common.api.modeling.TrackModelUpdates request) Description copied from interface:EventStoreClientLong-polls committed independent-model commit substeps after a client-controlled state cursor.- Specified by:
trackModelUpdatesin interfaceEventStoreClient
-
registerModelGraphProjection
public CompletableFuture<io.fluxzero.common.api.modeling.ModelGraphProjectionStatus> registerModelGraphProjection(io.fluxzero.common.api.modeling.RegisterModelGraphProjection request) Description copied from interface:EventStoreClientIdempotently registers an asynchronous materialized model-graph projection.- Specified by:
registerModelGraphProjectionin interfaceEventStoreClient
-
getModelGraphProjectionStatus
public io.fluxzero.common.api.modeling.ModelGraphProjectionStatus getModelGraphProjectionStatus(io.fluxzero.common.api.modeling.GetModelGraphProjectionStatus request) Description copied from interface:EventStoreClientReturns the current high-watermark and backlog for one materialized graph projection.- Specified by:
getModelGraphProjectionStatusin interfaceEventStoreClient
-
awaitModelGraphProjection
public CompletableFuture<io.fluxzero.common.api.modeling.ModelGraphProjectionStatus> awaitModelGraphProjection(io.fluxzero.common.api.modeling.AwaitModelGraphProjection request) Description copied from interface:EventStoreClientCompletes after every affected root in a graph projection has crossed the requested committed state boundary.- Specified by:
awaitModelGraphProjectionin interfaceEventStoreClient
-
planModelDeletion
public io.fluxzero.common.api.modeling.ModelDeletionPlan planModelDeletion(io.fluxzero.common.api.modeling.PlanModelDeletion request) Description copied from interface:EventStoreClientCreates a bounded, non-mutating plan for an explicit independent-model hard deletion.- Specified by:
planModelDeletionin interfaceEventStoreClient
-
deleteModel
public CompletableFuture<io.fluxzero.common.api.modeling.ModelDeletionResult> deleteModel(io.fluxzero.common.api.modeling.DeleteModel request) Description copied from interface:EventStoreClientExecutes or resumes an idempotent independent-model hard deletion.- Specified by:
deleteModelin interfaceEventStoreClient
-
getModelEvents
public io.fluxzero.common.api.modeling.GetModelEventsResult getModelEvents(io.fluxzero.common.api.modeling.GetModelEvents request) Description copied from interface:EventStoreClientBatch-loads independent model heads and event memberships at one pinned state boundary.- Specified by:
getModelEventsin interfaceEventStoreClient
-
getModelGraph
public io.fluxzero.common.api.modeling.GetModelGraphResult getModelGraph(io.fluxzero.common.api.modeling.GetModelGraph request) Description copied from interface:EventStoreClientLoads one bounded temporal model graph and an optional first page of its grouped model streams.- Specified by:
getModelGraphin interfaceEventStoreClient
-
getModelChange
public io.fluxzero.common.api.modeling.GetModelChangeResult getModelChange(io.fluxzero.common.api.modeling.GetModelChange request) Description copied from interface:EventStoreClientResolves the durable targets of one model-commit substep.- Specified by:
getModelChangein interfaceEventStoreClient
-
resolveRelatedModels
-
resolveCurrentGraph
-
resolveModelDocumentCollections
-
updateRelationships
public CompletableFuture<Void> updateRelationships(io.fluxzero.common.api.modeling.UpdateRelationships request) 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
public CompletableFuture<Void> repairRelationships(io.fluxzero.common.api.modeling.RepairRelationships request) 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<io.fluxzero.common.api.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
public CompletableFuture<Void> deleteEvents(String aggregateId, io.fluxzero.common.Guarantee guarantee) 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
public List<io.fluxzero.common.api.modeling.Relationship> getRelationships(io.fluxzero.common.api.modeling.GetRelationships request) 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
-
append
-
getBatch
-
getBatch
-
scanBatch
-
setRetentionTime
-
unwrap
-
getMessageStore
default io.fluxzero.common.tracking.MessageStore getMessageStore()
-