Class AbstractSnapshotPublisher

java.lang.Object
com.societegenerale.failover.observable.micrometer.AbstractSnapshotPublisher
All Implemented Interfaces:
SnapshotPublisher
Direct Known Subclasses:
ThresholdSnapshotPublisher

public abstract class AbstractSnapshotPublisher extends Object implements SnapshotPublisher
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 Details

    • AbstractSnapshotPublisher

      protected AbstractSnapshotPublisher(Executor executor)
  • Method Details

    • onPublish

      public void onPublish()
      Called on each metric event by MicrometerObservablePublisher. Dispatches an async SnapshotPublisher.push() when shouldPublish() returns true. 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:
      true to dispatch a push, false to skip