Class TracingSnapshotStore
- All Implemented Interfaces:
DescribableComponent,SnapshotStore
SnapshotStore decorator that opens internal tracing spans around the snapshot store / load
operations.
Each span carries the snapshot's qualified name as its trailing element ("SnapshotStore.store Booking") and
an axoniq.entity.id attribute holding the identifier.
This decorator is registered by EventSourcingTracingConfigurationEnhancer; it is never instantiated directly
by applications.
- Since:
- 5.3.0
- Author:
- Mateusz Nowak
-
Constructor Summary
ConstructorsConstructorDescriptionTracingSnapshotStore(SnapshotStore delegate, SpanFactory spanFactory) Initializes a tracingSnapshotStorewrapping the givendelegate, obtaining spans from the givenspanFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.CompletableFuture<@Nullable Snapshot> load(QualifiedName qualifiedName, Object identifier, @Nullable ProcessingContext context) Loads the latest snapshot for a given name and identifier.store(QualifiedName qualifiedName, Object identifier, Snapshot snapshot, @Nullable ProcessingContext context) Persists a snapshot under the given name and identifier.
-
Constructor Details
-
TracingSnapshotStore
Initializes a tracingSnapshotStorewrapping the givendelegate, obtaining spans from the givenspanFactory.- Parameters:
delegate- the snapshot store to delegate tospanFactory- the factory producing the tracing spans
-
-
Method Details
-
store
public CompletableFuture<Void> store(QualifiedName qualifiedName, Object identifier, Snapshot snapshot, @Nullable ProcessingContext context) Description copied from interface:SnapshotStorePersists a snapshot under the given name and identifier. This replaces any previous snapshot(s) with the same name and identifier.This method is asynchronous and returns a
CompletableFuturethat completes when the snapshot has been durably stored.- Specified by:
storein interfaceSnapshotStore- Parameters:
qualifiedName- the name of the snapshot to persist, cannot benullidentifier- the identifier of the snapshot to persist, cannot benullsnapshot- the snapshot to persist, cannot benullcontext- theProcessingContextactive while storing, used by decorators (e.g. tracing) to correlate the operation with the surrounding unit of work; may benull- Returns:
- a
CompletableFuturethat completes when the snapshot has been stored
-
load
public CompletableFuture<@Nullable Snapshot> load(QualifiedName qualifiedName, Object identifier, @Nullable ProcessingContext context) Description copied from interface:SnapshotStoreLoads the latest snapshot for a given name and identifier.The returned snapshot may have an older or newer version relative to what is expected. The caller is responsible for handling version compatibility or ignoring unusable snapshots.
This method is asynchronous and returns a
CompletableFuturethat completes with the snapshot if one exists, ornullif no snapshot is available.- Specified by:
loadin interfaceSnapshotStore- Parameters:
qualifiedName- the name of the snapshot, cannot benullidentifier- the identifier of the snapshot, cannot benullcontext- theProcessingContextactive while loading, used by decorators (e.g. tracing) to correlate the operation with the surrounding unit of work; may benull- Returns:
- a
CompletableFuturecontaining the snapshot, or containingnullif no matching snapshot exists
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.Best Practices: As a general rule, all relevant fields of a
DescribableComponentimplementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing thedescribeTomethod, who should focus on providing information that is useful for understanding the component's configuration and state.Example implementation:
public void describeTo(ComponentDescriptor descriptor) { descriptor.describeProperty("name", this.name); descriptor.describeProperty("enabled", this.enabled); descriptor.describeProperty("configuration", this.configuration); // A nested component descriptor.describeProperty("handlers", this.eventHandlers); // A collection }- Specified by:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-