Search in sources :

Example 1 with VertxCompletableFuture

use of io.gravitee.gateway.services.healthcheck.vertx.VertxCompletableFuture in project gravitee-gateway by gravitee-io.

the class GatewayProbe method check.

@Override
public CompletableFuture<Result> check() {
    VertxCompletableFuture<Result> result = new VertxCompletableFuture<>(vertx);
    NetClientOptions options = new NetClientOptions().setConnectTimeout(500);
    NetClient client = vertx.createNetClient(options);
    client.connect(port, host, res -> {
        if (res.succeeded()) {
            result.complete(Result.healthy());
        } else {
            result.complete(Result.unhealthy(res.cause()));
        }
        client.close();
    });
    return result;
}
Also used : NetClientOptions(io.vertx.core.net.NetClientOptions) NetClient(io.vertx.core.net.NetClient) VertxCompletableFuture(io.gravitee.gateway.services.healthcheck.vertx.VertxCompletableFuture) Result(io.gravitee.gateway.services.healthcheck.Result)

Aggregations

Result (io.gravitee.gateway.services.healthcheck.Result)1 VertxCompletableFuture (io.gravitee.gateway.services.healthcheck.vertx.VertxCompletableFuture)1 NetClient (io.vertx.core.net.NetClient)1 NetClientOptions (io.vertx.core.net.NetClientOptions)1