Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the default HealthCheckUpdateHandler #6002

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,11 @@ public HealthCheckServiceBuilder longPolling(long maxLongPollingTimeoutMillis,
*
* @return {@code this}
* @see #updatable(HealthCheckUpdateHandler)
* @see HealthCheckUpdateHandler#of()
*/
public HealthCheckServiceBuilder updatable(boolean updatable) {
if (updatable) {
return updatable(DefaultHealthCheckUpdateHandler.INSTANCE);
return updatable(HealthCheckUpdateHandler.of());
}

updateHandler = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.concurrent.CompletionStage;

import com.linecorp.armeria.common.HttpRequest;
import com.linecorp.armeria.common.annotation.UnstableApi;
import com.linecorp.armeria.server.HttpResponseException;
import com.linecorp.armeria.server.HttpStatusException;
import com.linecorp.armeria.server.Server;
Expand All @@ -28,6 +29,30 @@
*/
@FunctionalInterface
public interface HealthCheckUpdateHandler {

/**
* Returns the default {@link HealthCheckUpdateHandler} that accepts a JSON object which has a boolean
* property named {@code "healthy"} for a {@code PUT} or {@code POST} request. A JSON patch in a
* {@code PATCH} request is also accepted.
*
* <p>For example:
* <pre>{@code
* // Update healthiness of the server to unhealthy
* POST /internal/health HTTP/2.0
*
* { "healthy": false }
*
* // Patch healthiness of the server to unhealthy
* PATCH /internal/health HTTP/2.0
*
* [ { "op": "replace", "path": "/healthy", "value": false } ]
* }</pre>
*/
@UnstableApi
static HealthCheckUpdateHandler of() {
return DefaultHealthCheckUpdateHandler.INSTANCE;
}

/**
* Determines if the healthiness of the {@link Server} needs to be changed or not from the given
* {@link HttpRequest}.
Expand Down
Loading