ApplicationAvailability class abstract

Defines the contract for accessing and tracking an application's availability information, including both its liveness and readiness states.

This abstraction is used by systems responsible for:

  • Health and availability endpoints (/live, /ready)
  • Monitoring and observability tooling
  • Application lifecycle and orchestration systems
  • Internal components needing real-time state insight

Implementations store the latest availability state for each availability dimension and may also retain past AvailabilityEvent instances for audit or diagnostic purposes.

Responsibilities

  • Provide the current liveness and readiness states
  • Expose the latest availability event for each type
  • Allow retrieval of arbitrary availability states via generics
  • Provide default fallback states when none have been reported

Example

final availability = MyAvailabilityTracker();

if (availability.getLivenessState() == LivenessState.BROKEN) {
  // system requires restart
}

final readiness = availability.getReadinessState();
final lastEvent = availability.getLastEvent(Class<ReadinessState>());
Implementers

Constructors

ApplicationAvailability()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getLastEvent<S extends AvailabilityState>(Class<S> stateType) AvailabilityEvent<S>?
Returns the most recent AvailabilityEvent associated with availability type S.
getLivenessState() LivenessState
Returns the application's current liveness state, or a fallback value.
getReadinessState() ReadinessState
Returns the application's current readiness state, or a fallback value.
getState<S extends AvailabilityState>(Class<S> stateType) → S?
Retrieves the most recently known availability state of type S.
getStateOrDefault<S extends AvailabilityState>(Class<S> stateType, S defaultState) → S
Retrieves the availability state of type S, providing a default if needed.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited