All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.netflix.adminresources.HealthcheckResource Maven / Gradle / Ivy

There is a newer version: 2.9.2
Show newest version
package com.netflix.adminresources;

import com.google.inject.Inject;
import com.netflix.karyon.server.eureka.HealthCheckInvocationStrategy;
import com.sun.jersey.spi.resource.Singleton;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import java.util.concurrent.TimeoutException;

@Path("/v2/healthcheck")
@Singleton
public class HealthcheckResource {

    @Inject(optional = true)
    private HealthCheckInvocationStrategy invocationStrategy;

    @GET
    public Response doHealthCheck() {
        if (null != invocationStrategy) {
            try {
                int status = invocationStrategy.invokeCheck();
                return Response.status(status).build();

            } catch (TimeoutException e) {
                return Response.status(Response.Status.SERVICE_UNAVAILABLE).build();

            }

        } else {
            return Response.status(Response.Status.NOT_FOUND).build();

        }
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy