Class HealthCheckRegistry


  • public class HealthCheckRegistry
    extends java.lang.Object
    A registry for health checks.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.ConcurrentMap<java.lang.String,​HealthCheck> healthChecks  
      private static org.slf4j.Logger LOGGER  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.SortedSet<java.lang.String> getNames()
      Returns a set of the names of all registered health checks.
      void register​(java.lang.String name, HealthCheck healthCheck)
      Registers an application HealthCheck.
      HealthCheck.Result runHealthCheck​(java.lang.String name)
      Runs the health check with the given name.
      java.util.SortedMap<java.lang.String,​HealthCheck.Result> runHealthChecks()
      Runs the registered health checks and returns a map of the results.
      java.util.SortedMap<java.lang.String,​HealthCheck.Result> runHealthChecks​(java.util.concurrent.ExecutorService executor)
      Runs the registered health checks in parallel and returns a map of the results.
      void unregister​(java.lang.String name)
      Unregisters the application HealthCheck with the given name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • healthChecks

        private final java.util.concurrent.ConcurrentMap<java.lang.String,​HealthCheck> healthChecks
    • Constructor Detail

    • Method Detail

      • register

        public void register​(java.lang.String name,
                             HealthCheck healthCheck)
        Registers an application HealthCheck.
        Parameters:
        name - the name of the health check
        healthCheck - the HealthCheck instance
      • unregister

        public void unregister​(java.lang.String name)
        Unregisters the application HealthCheck with the given name.
        Parameters:
        name - the name of the HealthCheck instance
      • getNames

        public java.util.SortedSet<java.lang.String> getNames()
        Returns a set of the names of all registered health checks.
        Returns:
        the names of all registered health checks
      • runHealthCheck

        public HealthCheck.Result runHealthCheck​(java.lang.String name)
                                          throws java.util.NoSuchElementException
        Runs the health check with the given name.
        Parameters:
        name - the health check's name
        Returns:
        the result of the health check
        Throws:
        java.util.NoSuchElementException - if there is no health check with the given name
      • runHealthChecks

        public java.util.SortedMap<java.lang.String,​HealthCheck.Result> runHealthChecks()
        Runs the registered health checks and returns a map of the results.
        Returns:
        a map of the health check results
      • runHealthChecks

        public java.util.SortedMap<java.lang.String,​HealthCheck.Result> runHealthChecks​(java.util.concurrent.ExecutorService executor)
        Runs the registered health checks in parallel and returns a map of the results.
        Returns:
        a map of the health check results