Skip to content
Merged
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 @@ -45,6 +45,7 @@ class RequestHttpServerHandler implements Handler<HttpServerRequest> {
private static final Pattern SLASH = Pattern.compile(Pattern.quote("/"));

private static final String DISCOVER_PATH = "/discover";
private static final String HEALTH_PATH = "/health";

static final TextMapGetter<MultiMap> OTEL_TEXT_MAP_GETTER =
new TextMapGetter<>() {
Expand Down Expand Up @@ -75,7 +76,13 @@ public String get(@Nullable MultiMap carrier, String key) {
public void handle(HttpServerRequest request) {
URI uri = URI.create(request.uri());

// Let's first check if it's a discovery request
// health check
if (HEALTH_PATH.equalsIgnoreCase(uri.getPath())) {
this.handleHealthRequest(request);
return;
}

// Discovery request
if (DISCOVER_PATH.equalsIgnoreCase(uri.getPath())) {
this.handleDiscoveryRequest(request);
return;
Expand All @@ -85,7 +92,7 @@ public void handle(HttpServerRequest request) {
String[] pathSegments = SLASH.split(uri.getPath());
if (pathSegments.length < 3) {
LOG.warn(
"Path doesn't match the pattern /invoke/ServiceName/HandlerName nor /discover: '{}'",
"Path doesn't match the pattern /invoke/ServiceName/HandlerName nor /discover nor /health: '{}'",
request.path());
request.response().setStatusCode(NOT_FOUND.code()).end();
return;
Expand Down Expand Up @@ -172,4 +179,12 @@ private void handleDiscoveryRequest(HttpServerRequest request) {
.putHeader(CONTENT_TYPE, discoveryResponse.getContentType())
.end(Buffer.buffer(discoveryResponse.getSerializedManifest()));
}

private void handleHealthRequest(HttpServerRequest request) {
request
.response()
.setStatusCode(OK.code())
.putHeader(X_RESTATE_SERVER_KEY, X_RESTATE_SERVER_VALUE)
.end();
}
}