io.gravitee.node.api.healthcheck.Result Java Examples

The following examples show how to use io.gravitee.node.api.healthcheck.Result. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GraviteeApisProbe.java    From gravitee-management-rest-api with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Result> check() {
    Future<Result> future = Future.future();

    NetClientOptions options = new NetClientOptions().setConnectTimeout(500);
    NetClient client = vertx.createNetClient(options);

    client.connect(port, host, res -> {
        if (res.succeeded()) {
            future.complete(Result.healthy());
        } else {
            future.complete(Result.unhealthy(res.cause()));
        }

        client.close();
    });

    return VertxCompletableFuture.from(vertx, future);
}
 
Example #2
Source File: HttpServerProbe.java    From gravitee-gateway with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #3
Source File: HttpServerProbe.java    From graviteeio-access-management with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Result> check() {
    final CompletableFuture<Result> future = new CompletableFuture<>();

    NetClientOptions options = new NetClientOptions().setConnectTimeout(500);
    NetClient client = vertx.createNetClient(options);

    client.rxConnect(port, host)
            .subscribe(
                    socket -> future.complete(Result.healthy()),
                    error -> future.complete(Result.unhealthy(error.getCause())));
    return future;
}
 
Example #4
Source File: ManagementRepositoryProbe.java    From graviteeio-access-management with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Result> check() {
    // Search for an domain to check repository connection
    final CompletableFuture<Result> future = new CompletableFuture<>();

    domainRepository.findById(DOMAIN)
            .subscribe(
                    domain -> future.complete(Result.healthy()),
                    error -> future.complete(Result.unhealthy(error)),
                    () -> future.complete(Result.healthy())); // repository is up but returned no result

    return future;
}
 
Example #5
Source File: OAuth2RepositoryProbe.java    From graviteeio-access-management with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Result> check() {
    // Search for an oauth 2.0 token to check repository connection
    final CompletableFuture<Result> future = new CompletableFuture<>();

    accessTokenRepository.findByToken(TOKEN)
            .subscribe(
                    domain -> future.complete(Result.healthy()),
                    error -> future.complete(Result.unhealthy(error)),
                    () -> future.complete(Result.healthy())); // repository is up but returned no result

    return future;
}
 
Example #6
Source File: ManagementRepositoryProbe.java    From gravitee-management-rest-api with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<Result> check() {
    // Search for an event to check repository connection
    try {
        eventRepository.search(new EventCriteria.Builder()
                .from(System.currentTimeMillis()).to(System.currentTimeMillis()).build());
        return CompletableFuture.completedFuture(Result.healthy());
    } catch (Exception ex) {
        return CompletableFuture.completedFuture(Result.unhealthy(ex));
    }
}