Interface ConsistencyMarker
- All Known Implementing Classes:
AbstractConsistencyMarker,AggregateBasedConsistencyMarker,GlobalIndexConsistencyMarker
public interface ConsistencyMarker
Interface representing a point in an Event Stream up to where certain state has been made up-to-date. Typically,
consistency markers are provided by operations on an event stream that provide events for event sourcing purposes.
Consistency Markers are used to identify the expected position new events should be inserted at, in order to avoid
conflicts. If the actual insert position doesn't match the position described in this ConsistencyMarker, there may
have been a concurrency conflict.
- Since:
- 5.0.0
- Author:
- Allard Buijze, Steven van Beelen, Milan Savic, Sara Pellegrini, Michal Negacz, Marco Amann
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ConsistencyMarkerThe consistency marker representing the end of an event stream.static final ConsistencyMarkerThe consistency marker representing the start of an event stream.static final Context.ResourceKey<ConsistencyMarker> The ResourceKey under which consistency markers are stored in aContext. -
Method Summary
Modifier and TypeMethodDescriptionstatic ContextaddToContext(Context context, ConsistencyMarker consistencyMarker) lowerBound(ConsistencyMarker other) Returns a ConsistencyMarker that represents the lower bound ofthisand givenothermarkers.position()Reduces this consistency marker to a single position if possible.upperBound(ConsistencyMarker other) Returns a ConsistencyMarker that represents the upper bound ofthisand givenothermarkers.
-
Field Details
-
RESOURCE_KEY
The ResourceKey under which consistency markers are stored in aContext.- See Also:
-
ORIGIN
The consistency marker representing the start of an event stream. Effectively any event present in an event store would represent a conflict with this marker. -
INFINITY
The consistency marker representing the end of an event stream. Effectively no event present in an event store would represent a conflict with this marker.
-
-
Method Details
-
lowerBound
Returns a ConsistencyMarker that represents the lower bound ofthisand givenothermarkers. Effectively, this means that any events whose position in the event stream is beyond eitherthisor theothermarker, will also be beyond the returned marker.- Parameters:
other- The other marker to create the lower bound for- Returns:
- a ConsistencyMarker that represents the lower bound of two other markers
-
upperBound
Returns a ConsistencyMarker that represents the upper bound ofthisand givenothermarkers. Effectively, this means that only events whose position in the event stream is beyond boththisand theothermarker, will also be beyond the returned marker.- Parameters:
other- The other marker to create the upper bound for- Returns:
- a ConsistencyMarker that represents the upper bound of two other markers
-
position
Position position()Reduces this consistency marker to a single position if possible.- Returns:
- a
Position, nevernull - Throws:
IllegalStateException- if the marker could not be reduced to a single position
-
addToContext
- Parameters:
context- TheContextto add the giventokento.consistencyMarker- TheconsistencyMarkerto add to the givencontextusing theRESOURCE_KEY.- Returns:
- The given
contextwith the givenconsistencyMarkerattached to it.
-