Class ExternalServiceHealthCheck

java.lang.Object
com.codahale.metrics.health.HealthCheck
org.sdase.commons.server.healthcheck.helper.ExternalServiceHealthCheck

@ExternalHealthCheck public class ExternalServiceHealthCheck extends com.codahale.metrics.health.HealthCheck
Default health check for checking if an external URL returns status code 2xx when invoking a simple HTTP GET
  • Constructor Details

    • ExternalServiceHealthCheck

      public ExternalServiceHealthCheck(String url, int timeoutMillis)
      Parameters:
      url - the URL that is requested using GET
      timeoutMillis - the timeout for establishing the connection and waiting for data
    • ExternalServiceHealthCheck

      public ExternalServiceHealthCheck(String requestMethod, String url, int timeoutMillis)
      Parameters:
      requestMethod - the method to use for the check request, GET and HEAD are allowed values
      url - the URL that is requested using GET
      timeoutMillis - the timeout for establishing the connection and waiting for data
    • ExternalServiceHealthCheck

      public ExternalServiceHealthCheck(String url, int timeoutMillis, OpenConnectionFunction openConnection)
      Parameters:
      url - the URL that is requested using GET
      timeoutMillis - the timeout for establishing the connection and waiting for data
      openConnection - provider of the HttpURLConnection
    • ExternalServiceHealthCheck

      public ExternalServiceHealthCheck(String requestMethod, String url, int timeoutMillis, OpenConnectionFunction openConnection)
      Parameters:
      requestMethod - the method to use for the check request, GET and HEAD are allowed values
      url - the URL that is requested using GET
      timeoutMillis - the timeout for establishing the connection and waiting for data
      openConnection - provider of the HttpURLConnection
  • Method Details

    • check

      public com.codahale.metrics.health.HealthCheck.Result check() throws Exception
      Specified by:
      check in class com.codahale.metrics.health.HealthCheck
      Throws:
      Exception