Ecwid / consul-api

Java client for Consul HTTP API
Apache License 2.0
416 stars 177 forks source link

Docs on TTL checks #151

Open davidkarlsen opened 6 years ago

davidkarlsen commented 6 years ago

I can't find too much docs on the TTL check. It seems the API will only register the check - but not actually invoke the endpoint to keep it healthy? Maybe you could tell a bit more in the docs?

gouthamkunduru90 commented 5 years ago

@davidkarlsen Below is the link where you can find how to invoke TTL type check to set the status of the check to passing https://www.consul.io/api/agent/check.html#ttl-check-pass In the consul api code there is a class AgentConsulClient in which you have agentCheckPass method which will invoke api endpoint to keep check to be healthy

@Override public Response agentCheckPass(String checkId, String note, String token) { UrlParameters noteParameter = note != null ? new SingleUrlParameters("note", note) : null; UrlParameters tokenParameter = token != null ? new SingleUrlParameters("token", token) : null;

    RawResponse rawResponse = rawClient.makePutRequest("/v1/agent/check/pass/" + checkId, "", noteParameter, tokenParameter);

    if (rawResponse.getStatusCode() == 200) {
        return new Response<Void>(null, rawResponse);
    } else {
        throw new OperationException(rawResponse);
    }
}