Class AbstractSnapshotPublisher
java.lang.Object
com.societegenerale.failover.observable.micrometer.AbstractSnapshotPublisher
- All Implemented Interfaces:
SnapshotPublisher
- Direct Known Subclasses:
ThresholdSnapshotPublisher
Base for event-driven snapshot publishers. Receives an
Executor (injected by
autoconfiguration — typically a virtual-thread executor) and exposes onPublish() as
the entry point called by MicrometerObservablePublisher on every metric event.
Subclasses implement shouldPublish() to control when SnapshotPublisher.push() is dispatched,
and implement SnapshotPublisher.push() with the actual snapshot delivery logic.
- Author:
- Anand Manissery
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSnapshotPublisher(Executor executor) Creates a new publisher. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled on each metric event byMicrometerObservablePublisher.protected abstract booleanDecides whether a snapshot push should be dispatched on this event.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.societegenerale.failover.observable.micrometer.SnapshotPublisher
push
-
Constructor Details
-
AbstractSnapshotPublisher
Creates a new publisher.- Parameters:
executor- executor used to dispatchSnapshotPublisher.push()off the metric-event thread
-
-
Method Details
-
onPublish
public void onPublish()Called on each metric event byMicrometerObservablePublisher. Dispatches an asyncSnapshotPublisher.push()whenshouldPublish()returnstrue. Never blocks the caller. -
shouldPublish
protected abstract boolean shouldPublish()Decides whether a snapshot push should be dispatched on this event. Must be fast and non-blocking — called on the metric event thread.- Returns:
trueto dispatch a push,falseto skip
-