Class TracingEntityLifecycleHandler<I,E>
- Type Parameters:
I- the entity identifier typeE- the entity type
- All Implemented Interfaces:
DescribableComponent,EntityLifecycleHandler<I,,E> SourcingHandler<I,E>
EntityLifecycleHandler. Opens an internal sourcing span around
source(Object, ProcessingContext) - the parent for the SnapshotStore.load /
SnapshotStore.store spans produced by TracingSnapshotStore, plus the eventual event-replay spans
the framework emits underneath.
initialize and subscribe are pure pass-throughs (no span); they are not on the hot replay path and
adding spans there would only add noise to the trace.
- Since:
- 5.3.0
- Author:
- Mateusz Nowak
-
Constructor Summary
ConstructorsConstructorDescriptionTracingEntityLifecycleHandler(EntityLifecycleHandler<I, E> delegate, SpanFactory spanFactory, String entityTypeName) Initializes a tracingEntityLifecycleHandlerwrapping the givendelegate, obtaining spans from the givenspanFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.initialize(I identifier, ProcessingContext context) Creates a new instance of the entity for the given identifier.source(I identifier, ProcessingContext processingContext) Sources the entity identified by the givenidentifier.voidsubscribe(ManagedEntity<I, E> entity, ProcessingContext context) Subscribes the given managed entity to the event stream so it receives future state changes.
-
Constructor Details
-
TracingEntityLifecycleHandler
public TracingEntityLifecycleHandler(EntityLifecycleHandler<I, E> delegate, SpanFactory spanFactory, String entityTypeName) Initializes a tracingEntityLifecycleHandlerwrapping the givendelegate, obtaining spans from the givenspanFactory.- Parameters:
delegate- the lifecycle handler to delegate tospanFactory- the factory producing the tracing spansentityTypeName- the entity-type name used as the span suffix andaxoniq.entity.typeattribute. When unknown a generic value such as"entity"is acceptable; null is not.
-
-
Method Details
-
source
Description copied from interface:SourcingHandlerSources the entity identified by the givenidentifier.This method returns a
CompletableFuturethat completes when the entity has been fully reconstructed or evolved to its latest state.- Specified by:
sourcein interfaceSourcingHandler<I,E> - Parameters:
identifier- the identifier of the entity to source, cannot benullprocessingContext- theProcessingContextassociated with this sourcing operation, cannot benull- Returns:
- a
CompletableFuturethat completes with the sourced entity, nevernull
-
initialize
Description copied from interface:EntityLifecycleHandlerCreates a new instance of the entity for the given identifier.This operation is used when no prior state exists for the entity. The resulting instance represents the initial state before any events have been applied.
- Specified by:
initializein interfaceEntityLifecycleHandler<I,E> - Parameters:
identifier- the entity identifier, cannot benullcontext- the processing context, cannot benull- Returns:
- a newly initialized entity instance
-
subscribe
Description copied from interface:EntityLifecycleHandlerSubscribes the given managed entity to the event stream so it receives future state changes.After subscription, any newly appended events relevant to the entity are applied to its current state, keeping it synchronized with the event store for the remainder of its lifecycle.
- Specified by:
subscribein interfaceEntityLifecycleHandler<I,E> - Parameters:
entity- the managed entity to subscribecontext- the processing context
-
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.
-