Class AbstractHealthIndicator<T>

  • Type Parameters:
    T - The health indication type
    All Implemented Interfaces:
    io.micronaut.core.order.Ordered, HealthIndicator
    Direct Known Subclasses:
    DiskSpaceIndicator

    public abstract class AbstractHealthIndicator<T>
    extends java.lang.Object
    implements HealthIndicator

    A base health indicator class to extend from that catches exceptions thrown from the getHealthInformation() method and updates the HealthResult with the exception information.

    Since:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.concurrent.ExecutorService executorService  
      protected io.micronaut.health.HealthStatus healthStatus  
      • Fields inherited from interface io.micronaut.core.order.Ordered

        HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
    • Field Detail

      • executorService

        protected java.util.concurrent.ExecutorService executorService
      • healthStatus

        protected io.micronaut.health.HealthStatus healthStatus
    • Constructor Detail

      • AbstractHealthIndicator

        public AbstractHealthIndicator()
    • Method Detail

      • setExecutorService

        @Inject
        public void setExecutorService​(@Named("io")
                                       java.util.concurrent.ExecutorService executorService)
        Parameters:
        executorService - The executor service
      • getResult

        public org.reactivestreams.Publisher<HealthResult> getResult()
        Specified by:
        getResult in interface HealthIndicator
        Returns:
        A publisher that returns a HealthResult that provides the information necessary to build a response.
      • getHealthInformation

        protected abstract T getHealthInformation()
        Provides information (typically a Map) to be returned. Set the healthStatus field during execution, otherwise HealthStatus.UNKNOWN will be used.
        Returns:
        Any details to be included in the response.
      • getHealthResult

        protected HealthResult getHealthResult()
        Builds the whole health result.
        Returns:
        The health result to provide to the indicator.
      • getName

        protected abstract java.lang.String getName()
        Used to populate the HealthResult. Provides a key to go along with the health information.
        Returns:
        The name of the indicator