Class InMemoryEventStore

java.lang.Object
io.fluxzero.sdk.tracking.client.InMemoryMessageStore
io.fluxzero.sdk.persisting.eventsourcing.client.InMemoryEventStore
All Implemented Interfaces:
io.fluxzero.common.Monitored<List<io.fluxzero.common.api.SerializedMessage>>, io.fluxzero.common.tracking.HasMessageStore, io.fluxzero.common.tracking.MessageStore, EventStoreClient, AutoCloseable

public class InMemoryEventStore extends InMemoryMessageStore implements EventStoreClient
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 Details

    • InMemoryEventStore

      public InMemoryEventStore()
    • InMemoryEventStore

      public InMemoryEventStore(Duration messageExpiration)
  • Method Details

    • 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: EventStoreClient
      Stores events for a given aggregate with an explicit guarantee.
      Specified by:
      storeEvents in interface EventStoreClient
      Parameters:
      aggregateId - The aggregate ID.
      events - Events to store.
      storeOnly - If true, events will not be published.
      guarantee - The guarantee level for this operation.
      Returns:
      A future representing completion of the store operation.
    • updateRelationships

      public CompletableFuture<Void> updateRelationships(io.fluxzero.common.api.modeling.UpdateRelationships request)
      Description copied from interface: EventStoreClient
      Updates entity relationships in the event store (e.g. parent-child, references).
      Specified by:
      updateRelationships in interface EventStoreClient
      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: EventStoreClient
      Repairs entity relationships, e.g. by forcing re-evaluation of existing relationships.
      Specified by:
      repairRelationships in interface EventStoreClient
      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: EventStoreClient
      Retrieves the event stream for an aggregate with control over size and offset.
      Specified by:
      getEvents in interface EventStoreClient
      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: EventStoreClient
      Deletes all events for a specific aggregate with a given delivery guarantee.
      Specified by:
      deleteEvents in interface EventStoreClient
      Parameters:
      aggregateId - The aggregate ID.
      guarantee - The guarantee to apply.
      Returns:
      A future that completes when deletion is acknowledged.
    • getAggregateIds

      public Map<String,String> getAggregateIds(io.fluxzero.common.api.modeling.GetAggregateIds request)
      Description copied from interface: EventStoreClient
      Gets aggregate IDs based on a GetAggregateIds request.
      Specified by:
      getAggregateIds in interface EventStoreClient
      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: EventStoreClient
      Gets relationships based on a GetRelationships request.
      Specified by:
      getRelationships in interface EventStoreClient
      Parameters:
      request - The request containing filter parameters.
      Returns:
      A list of matching relationships.
    • toString

      public String toString()
      Overrides:
      toString in class InMemoryMessageStore