Interface EventStoreClient
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
InMemoryEventStore
,LocalEventStoreClient
,WebSocketEventStoreClient
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:
EventStore
AggregateRepository
- Static methods on
FluxCapacitor
, e.g.FluxCapacitor.loadAggregate(...)
.
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 Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the client and releases any open resources or connections.default CompletableFuture
<Void> deleteEvents
(String aggregateId) Deletes all events for a specific aggregate.deleteEvents
(String aggregateId, Guarantee guarantee) Deletes all events for a specific aggregate with a given delivery guarantee.getAggregateIds
(GetAggregateIds request) Gets aggregate IDs based on aGetAggregateIds
request.getAggregatesFor
(String entityId) Gets a map of aggregate IDs that reference a given entity ID.default AggregateEventStream
<SerializedMessage> Retrieves the full event stream for a given aggregate.default AggregateEventStream
<SerializedMessage> Retrieves the event stream for an aggregate starting after the given sequence number.Retrieves the event stream for an aggregate with control over size and offset.getRelationships
(GetRelationships request) Gets relationships based on aGetRelationships
request.default List
<Relationship> getRelationships
(String entityId) Gets relationships for the given entity.repairRelationships
(RepairRelationships request) Repairs entity relationships, e.g. by forcing re-evaluation of existing relationships.default CompletableFuture
<Void> storeEvents
(String aggregateId, List<SerializedMessage> events, boolean storeOnly) Stores a list of serialized events for a given aggregate identifier.storeEvents
(String aggregateId, List<SerializedMessage> events, boolean storeOnly, Guarantee guarantee) Stores events for a given aggregate with an explicit guarantee.updateRelationships
(UpdateRelationships request) Updates entity relationships in the event store (e.g. parent-child, references).
-
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
- Iftrue
, events will not be published.guarantee
- The guarantee level for this operation.- Returns:
- A future representing completion of the store operation.
-
getEvents
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
Deletes all events for a specific aggregate.- Parameters:
aggregateId
- The aggregate ID.- Returns:
- A future that completes when deletion is acknowledged.
-
deleteEvents
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
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
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
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
Gets aggregate IDs based on aGetAggregateIds
request.- Parameters:
request
- The request containing filtering options.- Returns:
- A map of aggregate IDs referencing the target entity.
-
getRelationships
Gets relationships for the given entity.- Parameters:
entityId
- The entity ID.- Returns:
- A list of matching relationships.
-
getRelationships
Gets relationships based on aGetRelationships
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 interfaceAutoCloseable
-