All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
InMemoryEventStore, LocalEventStoreClient, WebSocketEventStoreClient

public interface EventStoreClient extends AutoCloseable
Low-level client interface for interacting with the event store in Flux Capacitor.

This interface provides operations for storing, retrieving, and deleting event streams related to event-sourced aggregates, as well as managing entity relationships such as aggregate references and links.

Users rarely interact with this interface directly. Instead, they typically use higher-level abstractions such as:

This interface is backed either by:

  • a connection to the Flux Platform using a websocket-based implementation, or
  • an in-memory store used for testing or standalone development purposes.
See Also:
  • Method Details

    • storeEvents

      default CompletableFuture<Void> storeEvents(String aggregateId, List<SerializedMessage> events, boolean storeOnly)
      Stores a list of serialized events for a given aggregate identifier.
      Parameters:
      aggregateId - The ID of the aggregate.
      events - The serialized events to store.
      storeOnly - Whether to store the events without publishing them.
      Returns:
      A future that completes when the operation is acknowledged.
    • storeEvents

      CompletableFuture<Void> storeEvents(String aggregateId, List<SerializedMessage> events, boolean storeOnly, Guarantee guarantee)
      Stores events for a given aggregate with an explicit guarantee.
      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.
    • getEvents

      default AggregateEventStream<SerializedMessage> getEvents(String aggregateId)
      Retrieves the full event stream for a given aggregate.
      Parameters:
      aggregateId - The aggregate ID.
      Returns:
      A stream of serialized events.
    • getEvents

      default AggregateEventStream<SerializedMessage> getEvents(String aggregateId, long lastSequenceNumber)
      Retrieves the event stream for an aggregate starting after the given sequence number.
      Parameters:
      aggregateId - The aggregate ID.
      lastSequenceNumber - The sequence number to start from (exclusive).
      Returns:
      A stream of serialized events.
    • getEvents

      AggregateEventStream<SerializedMessage> getEvents(String aggregateId, long lastSequenceNumber, int maxSize)
      Retrieves the event stream for an aggregate with control over size and offset.
      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

      default CompletableFuture<Void> deleteEvents(String aggregateId)
      Deletes all events for a specific aggregate.
      Parameters:
      aggregateId - The aggregate ID.
      Returns:
      A future that completes when deletion is acknowledged.
    • deleteEvents

      CompletableFuture<Void> deleteEvents(String aggregateId, Guarantee guarantee)
      Deletes all events for a specific aggregate with a given delivery guarantee.
      Parameters:
      aggregateId - The aggregate ID.
      guarantee - The guarantee to apply.
      Returns:
      A future that completes when deletion is acknowledged.
    • updateRelationships

      CompletableFuture<Void> updateRelationships(UpdateRelationships request)
      Updates entity relationships in the event store (e.g. parent-child, references).
      Parameters:
      request - The update request.
      Returns:
      A future that completes when the operation is acknowledged.
    • repairRelationships

      CompletableFuture<Void> repairRelationships(RepairRelationships request)
      Repairs entity relationships, e.g. by forcing re-evaluation of existing relationships.
      Parameters:
      request - The repair request.
      Returns:
      A future that completes when the repair is done.
    • getAggregatesFor

      default Map<String,String> getAggregatesFor(String entityId)
      Gets a map of aggregate IDs that reference a given entity ID.
      Parameters:
      entityId - The entity identifier.
      Returns:
      A map of aggregate IDs and corresponding reference names.
    • getAggregateIds

      Map<String,String> getAggregateIds(GetAggregateIds request)
      Gets aggregate IDs based on a GetAggregateIds request.
      Parameters:
      request - The request containing filtering options.
      Returns:
      A map of aggregate IDs referencing the target entity.
    • getRelationships

      default List<Relationship> getRelationships(String entityId)
      Gets relationships for the given entity.
      Parameters:
      entityId - The entity ID.
      Returns:
      A list of matching relationships.
    • getRelationships

      List<Relationship> getRelationships(GetRelationships request)
      Gets relationships based on a GetRelationships request.
      Parameters:
      request - The request containing filter parameters.
      Returns:
      A list of matching relationships.
    • close

      void close()
      Closes the client and releases any open resources or connections.
      Specified by:
      close in interface AutoCloseable