/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.reactivex.ext.healthchecks;

import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.Maybe;
import io.vertx.ext.healthchecks.Status;
import io.vertx.core.Handler;

A Vert.x Web handler on which you register health check procedure. It computes the outcome status (`UP` or `DOWN`) . When the handler process a 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 RX-ified interface using Vert.x codegen.
/** * A Vert.x Web handler on which you register health check procedure. It computes the outcome status (`UP` or `DOWN`) * . When the handler process a HTTP request, it computes the global outcome and build a HTTP response as follows: * <p> * <ul> * <li>204 - status is `UP` but no procedures installed (no payload)</li> * <li>200 - status is `UP`, the payload contains the result of the installed procedures</li> * <li>503 - status is `DOWN`, the payload contains the result of the installed procedures</li> * <li>500 - status is `DOWN`, the payload contains the result of the installed procedures, one of the * procedure has failed</li> * </ul> * * <p/> * NOTE: This class has been automatically generated from the {@link io.vertx.ext.healthchecks.HealthCheckHandler original} non RX-ified interface using Vert.x codegen. */
@io.vertx.lang.rx.RxGen(io.vertx.ext.healthchecks.HealthCheckHandler.class) public class HealthCheckHandler implements io.vertx.core.Handler<io.vertx.reactivex.ext.web.RoutingContext> { @Override public String toString() { return delegate.toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; HealthCheckHandler that = (HealthCheckHandler) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final io.vertx.lang.rx.TypeArg<HealthCheckHandler> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new HealthCheckHandler((io.vertx.ext.healthchecks.HealthCheckHandler) obj), HealthCheckHandler::getDelegate ); private final io.vertx.ext.healthchecks.HealthCheckHandler delegate; public HealthCheckHandler(io.vertx.ext.healthchecks.HealthCheckHandler delegate) { this.delegate = delegate; } public io.vertx.ext.healthchecks.HealthCheckHandler getDelegate() { return delegate; }
Something has happened, so handle it.
Params:
  • event – the event to handle
/** * Something has happened, so handle it. * @param event the event to handle */
public void handle(io.vertx.reactivex.ext.web.RoutingContext event) { delegate.handle(event.getDelegate()); }
Creates an instance of the default implementation of the HealthCheckHandler. This function creates a new instance of HealthChecks.
Params:
  • vertx – the Vert.x instance, must not be null
  • provider – the Authentication provider used to authenticate the HTTP request
Returns:the created instance
/** * Creates an instance of the default implementation of the {@link io.vertx.reactivex.ext.healthchecks.HealthCheckHandler}. * This function creates a new instance of {@link io.vertx.reactivex.ext.healthchecks.HealthChecks}. * @param vertx the Vert.x instance, must not be <code>null</code> * @param provider the Authentication provider used to authenticate the HTTP request * @return the created instance */
public static io.vertx.reactivex.ext.healthchecks.HealthCheckHandler create(io.vertx.reactivex.core.Vertx vertx, io.vertx.reactivex.ext.auth.AuthProvider provider) { io.vertx.reactivex.ext.healthchecks.HealthCheckHandler ret = io.vertx.reactivex.ext.healthchecks.HealthCheckHandler.newInstance(io.vertx.ext.healthchecks.HealthCheckHandler.create(vertx.getDelegate(), provider.getDelegate())); return ret; }
Creates an instance of the default implementation of the HealthCheckHandler. This function creates a new instance of HealthChecks.
Params:
  • vertx – the Vert.x instance, must not be null
Returns:the created instance
/** * Creates an instance of the default implementation of the {@link io.vertx.reactivex.ext.healthchecks.HealthCheckHandler}. * This function creates a new instance of {@link io.vertx.reactivex.ext.healthchecks.HealthChecks}. * @param vertx the Vert.x instance, must not be <code>null</code> * @return the created instance */
public static io.vertx.reactivex.ext.healthchecks.HealthCheckHandler create(io.vertx.reactivex.core.Vertx vertx) { io.vertx.reactivex.ext.healthchecks.HealthCheckHandler ret = io.vertx.reactivex.ext.healthchecks.HealthCheckHandler.newInstance(io.vertx.ext.healthchecks.HealthCheckHandler.create(vertx.getDelegate())); return ret; }
Creates an instance of the default implementation of the HealthCheckHandler.
Params:
  • hc – the health checks object to use, must not be null
  • provider –
Returns:the created instance
/** * Creates an instance of the default implementation of the {@link io.vertx.reactivex.ext.healthchecks.HealthCheckHandler}. * @param hc the health checks object to use, must not be <code>null</code> * @param provider * @return the created instance */
public static io.vertx.reactivex.ext.healthchecks.HealthCheckHandler createWithHealthChecks(io.vertx.reactivex.ext.healthchecks.HealthChecks hc, io.vertx.reactivex.ext.auth.AuthProvider provider) { io.vertx.reactivex.ext.healthchecks.HealthCheckHandler ret = io.vertx.reactivex.ext.healthchecks.HealthCheckHandler.newInstance(io.vertx.ext.healthchecks.HealthCheckHandler.createWithHealthChecks(hc.getDelegate(), provider.getDelegate())); return ret; }
Creates an instance of the default implementation of the HealthCheckHandler.
Params:
  • hc – the health checks object to use
Returns:the created instance
/** * Creates an instance of the default implementation of the {@link io.vertx.reactivex.ext.healthchecks.HealthCheckHandler}. * @param hc the health checks object to use * @return the created instance */
public static io.vertx.reactivex.ext.healthchecks.HealthCheckHandler createWithHealthChecks(io.vertx.reactivex.ext.healthchecks.HealthChecks hc) { io.vertx.reactivex.ext.healthchecks.HealthCheckHandler ret = io.vertx.reactivex.ext.healthchecks.HealthCheckHandler.newInstance(io.vertx.ext.healthchecks.HealthCheckHandler.createWithHealthChecks(hc.getDelegate())); return ret; }
Registers a health check procedure.

The procedure is a taking a of Status as parameter. Procedures are asynchronous, and must complete or fail the given . 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.

Params:
  • name – the name of the procedure, must not be null or empty
  • procedure – the procedure, must not be null
Returns:the current HealthCheckHandler
/** * Registers a health check procedure. * <p> * The procedure is a taking a of {@link io.vertx.ext.healthchecks.Status} as parameter. Procedures are * asynchronous, and <strong>must</strong> complete or fail the given . 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) {@link io.vertx.ext.healthchecks.Status}, the * procedure outcome is the received status. * <p> * This method uses a 1s timeout. To configure the timeout use {@link io.vertx.reactivex.ext.healthchecks.HealthCheckHandler#register}. * @param name the name of the procedure, must not be <code>null</code> or empty * @param procedure the procedure, must not be <code>null</code> * @return the current {@link io.vertx.reactivex.ext.healthchecks.HealthCheckHandler} */
public io.vertx.reactivex.ext.healthchecks.HealthCheckHandler register(String name, Handler<io.vertx.reactivex.core.Promise<Status>> procedure) { delegate.register(name, new Handler<io.vertx.core.Promise<io.vertx.ext.healthchecks.Status>>() { public void handle(io.vertx.core.Promise<io.vertx.ext.healthchecks.Status> event) { procedure.handle(io.vertx.reactivex.core.Promise.newInstance(event, io.vertx.lang.rx.TypeArg.unknown())); } }); return this; }
Registers a health check procedure.

The procedure is a taking a of Status as parameter. Procedures are asynchronous, and must complete or fail the given . 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.

Params:
  • 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
/** * Registers a health check procedure. * <p> * The procedure is a taking a of {@link io.vertx.ext.healthchecks.Status} as parameter. Procedures are * asynchronous, and <strong>must</strong> complete or fail the given . 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) {@link io.vertx.ext.healthchecks.Status}, the * procedure outcome is the received status. * @param name the name of the procedure, must not be <code>null</code> or empty * @param timeout the procedure timeout * @param procedure the procedure, must not be <code>null</code> * @return the current {@link io.vertx.reactivex.ext.healthchecks.HealthCheckHandler} */
public io.vertx.reactivex.ext.healthchecks.HealthCheckHandler register(String name, long timeout, Handler<io.vertx.reactivex.core.Promise<Status>> procedure) { delegate.register(name, timeout, new Handler<io.vertx.core.Promise<io.vertx.ext.healthchecks.Status>>() { public void handle(io.vertx.core.Promise<io.vertx.ext.healthchecks.Status> event) { procedure.handle(io.vertx.reactivex.core.Promise.newInstance(event, io.vertx.lang.rx.TypeArg.unknown())); } }); return this; }
Unregisters a procedure.
Params:
  • name – the name of the procedure
Returns:the current HealthCheckHandler
/** * Unregisters a procedure. * @param name the name of the procedure * @return the current {@link io.vertx.reactivex.ext.healthchecks.HealthCheckHandler} */
public io.vertx.reactivex.ext.healthchecks.HealthCheckHandler unregister(String name) { delegate.unregister(name); return this; } public static HealthCheckHandler newInstance(io.vertx.ext.healthchecks.HealthCheckHandler arg) { return arg != null ? new HealthCheckHandler(arg) : null; } }