Class HealthCheckHandler

java.lang.Object
io.vertx.mutiny.ext.web.healthchecks.HealthCheckHandler
All Implemented Interfaces:
MutinyDelegate, io.vertx.core.Handler<RoutingContext>, Consumer<RoutingContext>

public class HealthCheckHandler extends Object implements io.vertx.core.Handler<RoutingContext>, Consumer<RoutingContext>, MutinyDelegate
A Vert.x Web handler on which you register health check procedure. It computes the outcome status (`UP` or `DOWN`) . When the handler process an HTTP request, it computes the global outcome and build a HTTP response as follows:

  • 204 - status is `UP` but no procedures installed (no payload)
  • 200 - status is `UP`, the payload contains the result of the installed procedures
  • 503 - status is `DOWN`, the payload contains the result of the installed procedures
  • 500 - status is `DOWN`, the payload contains the result of the installed procedures, one of the procedure has failed

NOTE: This class has been automatically generated from the original non Mutiny-ified interface.

Author:
Clement Escoffier
See Also:
  • HealthCheckHandler
  • Field Details

  • Constructor Details

    • HealthCheckHandler

      public HealthCheckHandler(io.vertx.ext.web.healthchecks.HealthCheckHandler delegate)
      Create a new instance of HealthCheckHandler delegating to the given (non-null) instance of HealthCheckHandler.
    • HealthCheckHandler

      public HealthCheckHandler(Object delegate)
  • Method Details

    • accept

      public void accept(RoutingContext item)
      Handle an item. This method is generated from the original method."
      Specified by:
      accept in interface Consumer<RoutingContext>
    • handle

      public void handle(RoutingContext item)
      Handle an item. This method is generated from the original method."
      Specified by:
      handle in interface io.vertx.core.Handler<RoutingContext>
    • getDelegate

      public io.vertx.ext.web.healthchecks.HealthCheckHandler getDelegate()
      Get the delegate instance.

      This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.

      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate instance
    • create

      public static HealthCheckHandler create(Vertx vertx, AuthenticationProvider provider)
      Creates an instance of the default implementation of the HealthCheckHandler. This function creates a new instance of HealthChecks.
      Parameters:
      vertx - the Vert.x instance, must not be null
      provider - the Authentication provider used to authenticate the HTTP request
      Returns:
      the created instance
    • create

      public static HealthCheckHandler create(Vertx vertx)
      Creates an instance of the default implementation of the HealthCheckHandler. This function creates a new instance of HealthChecks.
      Parameters:
      vertx - the Vert.x instance, must not be null
      Returns:
      the created instance
    • createWithHealthChecks

      public static HealthCheckHandler createWithHealthChecks(io.vertx.ext.healthchecks.HealthChecks hc, AuthenticationProvider provider)
      Creates an instance of the default implementation of the HealthCheckHandler.
      Parameters:
      hc - the health checks object to use, must not be null
      Returns:
      the created instance
    • createWithHealthChecks

      public static HealthCheckHandler createWithHealthChecks(io.vertx.ext.healthchecks.HealthChecks hc)
      Creates an instance of the default implementation of the HealthCheckHandler.
      Parameters:
      hc - the health checks object to use
      Returns:
      the created instance
    • register

      public HealthCheckHandler register(String name, io.smallrye.mutiny.Uni<io.vertx.ext.healthchecks.Status> procedure)
      Registers a health check procedure.

      The procedure is a Handler taking a Promise of Status as parameter. Procedures are asynchronous, and must complete or fail the given Promise. If the future object is failed, the procedure outcome is considered as `DOWN`. If the future is completed without any object, the procedure outcome is considered as `UP`. If the future is completed with a (not-null) Status, the procedure outcome is the received status.

      This method uses a 1s timeout. To configure the timeout use #register(String, long, Handler).

      Parameters:
      name - the name of the procedure, must not be null or empty
      procedure - the procedure, must not be null
      Returns:
      the current HealthCheckHandler
    • register

      public HealthCheckHandler register(String name, long timeout, io.smallrye.mutiny.Uni<io.vertx.ext.healthchecks.Status> procedure)
      Registers a health check procedure.

      The procedure is a Handler taking a Promise of Status as parameter. Procedures are asynchronous, and must complete or fail the given Promise. If the future object is failed, the procedure outcome is considered as `DOWN`. If the future is completed without any object, the procedure outcome is considered as `UP`. If the future is completed with a (not-null) Status, the procedure outcome is the received status.

      Parameters:
      name - the name of the procedure, must not be null or empty
      timeout - the procedure timeout
      procedure - the procedure, must not be null
      Returns:
      the current HealthCheckHandler
    • unregister

      public HealthCheckHandler unregister(String name)
      Unregisters a procedure.
      Parameters:
      name - the name of the procedure
      Returns:
      the current HealthCheckHandler
    • resultMapper

      public HealthCheckHandler resultMapper(Function<io.vertx.ext.healthchecks.CheckResult,io.smallrye.mutiny.Uni<io.vertx.ext.healthchecks.CheckResult>> resultMapper)
      Sets a function which will be invoked before the CheckResult gets written to clients.
      Parameters:
      resultMapper - the Function used to manipulate the CheckResult, null means no result mapper function enabled.
      Returns:
      the current HealthCheckHandler
    • newInstance

      public static HealthCheckHandler newInstance(io.vertx.ext.web.healthchecks.HealthCheckHandler delegate)
      Creates a new instance of the HealthCheckHandler.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object