Module io.fluxzero.sdk
Interface EventStoreClient
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
InMemoryEventStore,LocalEventStoreClient,WebSocketEventStoreClient
Low-level client interface for interacting with the event store in Fluxzero.
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:
EventStoreAggregateRepository- Static methods on
Fluxzero, e.g.Fluxzero.loadAggregate(...).
This interface is backed either by:
- a connection to the Fluxzero Runtime using a websocket-based implementation, or
- an in-memory store used for testing or standalone development purposes.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()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, io.fluxzero.common.Guarantee guarantee) Deletes all events for a specific aggregate with a given delivery guarantee.getAggregateIds(io.fluxzero.common.api.modeling.GetAggregateIds request) Gets aggregate IDs based on aGetAggregateIdsrequest.getAggregatesFor(String entityId) Gets a map of aggregate IDs that reference a given entity ID.default AggregateEventStream<io.fluxzero.common.api.SerializedMessage> Retrieves the full event stream for a given aggregate.default AggregateEventStream<io.fluxzero.common.api.SerializedMessage> Retrieves the event stream for an aggregate starting after the given sequence number.AggregateEventStream<io.fluxzero.common.api.SerializedMessage> Retrieves the event stream for an aggregate with control over size and offset.List<io.fluxzero.common.api.modeling.Relationship> getRelationships(io.fluxzero.common.api.modeling.GetRelationships request) Gets relationships based on aGetRelationshipsrequest.default List<io.fluxzero.common.api.modeling.Relationship> getRelationships(String entityId) Gets relationships for the given entity.repairRelationships(io.fluxzero.common.api.modeling.RepairRelationships request) Repairs entity relationships, e.g. by forcing re-evaluation of existing relationships.default CompletableFuture<Void> storeEvents(String aggregateId, List<io.fluxzero.common.api.SerializedMessage> events, boolean storeOnly) Stores a list of serialized events for a given aggregate identifier.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.updateRelationships(io.fluxzero.common.api.modeling.UpdateRelationships request) Updates entity relationships in the event store (e.g. parent-child, references).
-
Method Details
-
storeEvents
default CompletableFuture<Void> storeEvents(String aggregateId, List<io.fluxzero.common.api.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<io.fluxzero.common.api.SerializedMessage> events, boolean storeOnly, io.fluxzero.common.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
default AggregateEventStream<io.fluxzero.common.api.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<io.fluxzero.common.api.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<io.fluxzero.common.api.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
CompletableFuture<Void> updateRelationships(io.fluxzero.common.api.modeling.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(io.fluxzero.common.api.modeling.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
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 aGetAggregateIdsrequest.- 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
List<io.fluxzero.common.api.modeling.Relationship> getRelationships(io.fluxzero.common.api.modeling.GetRelationships request) Gets relationships based on aGetRelationshipsrequest.- 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:
closein interfaceAutoCloseable
-