public interface StorageStrategy
Modifier and Type | Method and Description |
---|---|
void |
appendEvents(com.mongodb.client.MongoCollection<org.bson.Document> eventCollection,
List<? extends EventMessage<?>> events,
Serializer serializer)
Appends the given list of
events to the given eventCollection . |
void |
appendSnapshot(com.mongodb.client.MongoCollection<org.bson.Document> snapshotCollection,
DomainEventMessage<?> snapshot,
Serializer serializer)
Append the given aggregate
snapshot to the snapshotCollection . |
TrackingToken |
createTailToken(com.mongodb.client.MongoCollection<org.bson.Document> eventsCollection)
Creates a token that is at the tail of an event stream - that tracks events from the beginning of time.
|
void |
deleteSnapshots(com.mongodb.client.MongoCollection<org.bson.Document> snapshotCollection,
String aggregateIdentifier,
long sequenceNumber)
Delete all snapshots of the aggregate with given
aggregateIdentifier from the given snapshotCollection , whose sequence number is lower than the given sequenceNumber . |
void |
ensureIndexes(com.mongodb.client.MongoCollection<org.bson.Document> eventsCollection,
com.mongodb.client.MongoCollection<org.bson.Document> snapshotsCollection)
Ensure that the correct indexes are in place.
|
List<? extends DomainEventData<?>> |
findDomainEvents(com.mongodb.client.MongoCollection<org.bson.Document> eventCollection,
String aggregateIdentifier,
long firstSequenceNumber,
int batchSize)
Returns a batch of events for an aggregate with given
aggregateIdentifier and a sequence number equal or
higher than the given firstSequenceNumber . |
Optional<? extends DomainEventData<?>> |
findLastSnapshot(com.mongodb.client.MongoCollection<org.bson.Document> snapshotCollection,
String aggregateIdentifier)
Finds the entry containing the last snapshot event for an aggregate with given
aggregateIdentifier
in the given collection . |
List<? extends TrackedEventData<?>> |
findTrackedEvents(com.mongodb.client.MongoCollection<org.bson.Document> eventCollection,
TrackingToken lastToken,
int batchSize)
Returns a batch of tracked events with a tracking token above the given
lastToken . |
Optional<Long> |
lastSequenceNumberFor(com.mongodb.client.MongoCollection<org.bson.Document> eventsCollection,
String aggregateIdentifier)
Return the last known sequence number for an Aggregate with given
aggregateIdentifier , whose Events are
stored in the given eventsCollection . |
void appendEvents(com.mongodb.client.MongoCollection<org.bson.Document> eventCollection, List<? extends EventMessage<?>> events, Serializer serializer)
events
to the given eventCollection
. Use the given serializer
to serialize the payload and metadata of the events.eventCollection
- the document collection that contains event entriesevents
- the event messages to append to the event collectionserializer
- the serializer used to serialize the event payload and metadatavoid appendSnapshot(com.mongodb.client.MongoCollection<org.bson.Document> snapshotCollection, DomainEventMessage<?> snapshot, Serializer serializer)
snapshot
to the snapshotCollection
. Use the given serializer
to serialize the payload and metadata of the snapshot.snapshotCollection
- the document collection that contains aggregate snapshot entriessnapshot
- the snapshot event message to append to the event collectionserializer
- the serializer used to serialize the payload and metadata of the snapshot eventvoid deleteSnapshots(com.mongodb.client.MongoCollection<org.bson.Document> snapshotCollection, String aggregateIdentifier, long sequenceNumber)
aggregateIdentifier
from the given snapshotCollection
, whose sequence number is lower than the given sequenceNumber
.snapshotCollection
- the document collection that contains aggregate snapshot entriesaggregateIdentifier
- the identifier of the aggregate for which to delete all snapshotssequenceNumber
- The sequenceNumber representing the upper bound (exclusive) of the snapshots to deleteList<? extends DomainEventData<?>> findDomainEvents(com.mongodb.client.MongoCollection<org.bson.Document> eventCollection, String aggregateIdentifier, long firstSequenceNumber, int batchSize)
aggregateIdentifier
and a sequence number equal or
higher than the given firstSequenceNumber
. The returned documents should be ordered chronologically
(typically by using the sequence number). The size of the returned list should not exceed the given batchSize
.eventCollection
- The collection in which to find the eventsaggregateIdentifier
- The identifier of the aggregate to queryfirstSequenceNumber
- The sequence number of the first event to returnbatchSize
- The maximum number of event entries to fetchList<? extends TrackedEventData<?>> findTrackedEvents(com.mongodb.client.MongoCollection<org.bson.Document> eventCollection, TrackingToken lastToken, int batchSize)
lastToken
. If lastToken
is null
the first (oldest) batch of entries in the store should be returned.
The returned documents should be ordered chronologically (typically by using the timestamp of the event). The
size of the returned list should not exceed the given batchSize
.
eventCollection
- The collection in which to find the eventslastToken
- the token of the last event in the previous batch or null
to load the oldest batchbatchSize
- The maximum number of event entries to fetchOptional<? extends DomainEventData<?>> findLastSnapshot(com.mongodb.client.MongoCollection<org.bson.Document> snapshotCollection, String aggregateIdentifier)
aggregateIdentifier
in the given collection
.snapshotCollection
- The collection to find the last snapshot event inaggregateIdentifier
- The identifier of the aggregate to find a snapshot forvoid ensureIndexes(com.mongodb.client.MongoCollection<org.bson.Document> eventsCollection, com.mongodb.client.MongoCollection<org.bson.Document> snapshotsCollection)
eventsCollection
- The collection containing the documents representing commits and events.snapshotsCollection
- The collection containing the document representing snapshotsOptional<Long> lastSequenceNumberFor(com.mongodb.client.MongoCollection<org.bson.Document> eventsCollection, String aggregateIdentifier)
aggregateIdentifier
, whose Events are
stored in the given eventsCollection
.eventsCollection
- The Collection in which to search for EventsaggregateIdentifier
- The aggregate to find the last sequence number forTrackingToken createTailToken(com.mongodb.client.MongoCollection<org.bson.Document> eventsCollection)
null
is returnedCopyright © 2010–2018. All rights reserved.