Interface JobObserver<T extends JobEvent>

Type Parameters:
T - the type of JobEvent this observer handles
All Known Implementing Classes:
AbstractWorkflowObserver, AgentTrace, BenchmarkRace, CostLedger, DecisionTrace, EventLogger, Heart, MicrometerObserver, OpenTelemetryObserver, Stethoscope, StreamingLogObserver, SystemHealthReporter

public interface JobObserver<T extends JobEvent>
Observer interface for handling job events; observe(T) is its one abstract method, so a lambda is an observer. Runs in a dedicated virtual thread with isolated resources.
Since:
0.1 (2025-09-14)
Author:
Andrey Santrosyan
  • Method Summary

    Modifier and Type
    Method
    Description
    default Predicate<T>
    Returns a predicate for filtering events at the MessageBus level.
    default boolean
    Checks if this observer should be considered stale and eligible for cleanup.
    void
    observe(T event)
    Process a job event.
  • Method Details

    • getPredicate

      default Predicate<T> getPredicate()
      Returns a predicate for filtering events at the MessageBus level. Called once during subscription.
      Returns:
      predicate to filter events, or null to accept all events of type T
    • observe

      void observe(T event)
      Process a job event. Runs in a separate virtual thread. Must handle its own resources and exceptions.
      Parameters:
      event - the job event to process
    • isStale

      default boolean isStale()
      Checks if this observer should be considered stale and eligible for cleanup. Called periodically by the MessageBus cleanup mechanism.

      Observers can implement this to indicate when they should be automatically unsubscribed (e.g., after a period of inactivity or reaching a max event count).

      Returns:
      true if this observer is stale and should be cleaned up, false otherwise