Class SnapshotSourcingConfigurationEnhancer
- All Implemented Interfaces:
ConfigurationEnhancer
ConfigurationEnhancer making the EventStorageEngine support the
snapshot sourcing strategy, by decorating it with the configured
SnapshotStore through SnapshotCapableEventStorageEngine.decorate(EventStorageEngine, SnapshotStore).
The engine is left as is when no SnapshotStore is configured, and when it is the configured
SnapshotStore itself. The latter resolves the snapshot within its own source call, in a single round
trip, which decorating would undo.
Registered by EventSourcingConfigurationDefaults, so applications registering those defaults manually receive
it as well. It is deliberately not contributed through the ServiceLoader, unlike its sibling
enhancers, to keep that single registration channel. Registered for the current registry only, since the defaults registering it are copied into every module registry and would otherwise
register it there a second time.
A storage topology composing snapshot sourcing itself disables this enhancer, taking over that responsibility:
configurer.componentRegistry(
registry -> registry.disableEnhancer(SnapshotSourcingConfigurationEnhancer.class)
);
An engine routing source to one engine per shard, tenant, or region is the case this exists for: the shard is
only known once a message is inspected, so decorating the routing engine would resolve snapshots before then, and the
engines it routes to would never receive the snapshot sourcing strategy. Such a topology composes each of its engines
with that engine's own snapshot store instead, through the same
decorate operation.
Disabling this enhancer without composing snapshot sourcing elsewhere leaves snapshots being written while never being read: sourcing then replays an entity's full event history.
- Since:
- 5.3.0
- Author:
- Laura Devriendt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe order ofthisenhancer compared to others, equal to 10 positions afterEventSourcingConfigurationDefaults(thus,EventSourcingConfigurationDefaults.ENHANCER_ORDER+ 10). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidenhance(ComponentRegistry registry) intorder()Returns the relative order this enhancer should be invoked in, compared to other instances.
-
Field Details
-
ENHANCER_ORDER
public static final int ENHANCER_ORDERThe order ofthisenhancer compared to others, equal to 10 positions afterEventSourcingConfigurationDefaults(thus,EventSourcingConfigurationDefaults.ENHANCER_ORDER+ 10).What this order governs is the window in which
thisenhancer can still be disabled: a disable is only recorded while the enhancer has not been invoked yet, and is otherwise reported as having no effect. Running late therefore leaves every earlier-ordered enhancer free to take over snapshot composition.- See Also:
-
-
Constructor Details
-
SnapshotSourcingConfigurationEnhancer
public SnapshotSourcingConfigurationEnhancer()
-
-
Method Details
-
order
public int order()Description copied from interface:ConfigurationEnhancerReturns the relative order this enhancer should be invoked in, compared to other instances.Use lower (negative) values for enhancers providing sensible defaults, and higher values for enhancers that should be able to override values potentially previously set. Defaults to
0when not set.- Specified by:
orderin interfaceConfigurationEnhancer- Returns:
- The order in which this enhancer should be invoked.
-
enhance
Description copied from interface:ConfigurationEnhancer- Specified by:
enhancein interfaceConfigurationEnhancer- Parameters:
registry- The registry instance to enhance.
-