mirror of
https://github.com/enso-org/enso.git
synced 2024-11-22 03:32:23 +03:00
Add healthcheck route to Ydoc (#11545)
close #10299 Changelog: - add: `/_health` route
This commit is contained in:
parent
3181374392
commit
03dc77006b
@ -3,9 +3,11 @@ package org.enso.ydoc.polyfill.web;
|
||||
import io.helidon.common.buffers.BufferData;
|
||||
import io.helidon.http.Headers;
|
||||
import io.helidon.http.HttpPrologue;
|
||||
import io.helidon.http.Method;
|
||||
import io.helidon.webclient.websocket.WsClient;
|
||||
import io.helidon.webclient.websocket.WsClientProtocolConfig;
|
||||
import io.helidon.webserver.WebServer;
|
||||
import io.helidon.webserver.http.HttpRouting;
|
||||
import io.helidon.webserver.websocket.WsRouting;
|
||||
import io.helidon.websocket.WsListener;
|
||||
import io.helidon.websocket.WsSession;
|
||||
@ -130,7 +132,7 @@ final class WebSocket implements Polyfill, ProxyExecutable {
|
||||
var port = arguments[2].asInt();
|
||||
var handleConnect = arguments[3];
|
||||
|
||||
var routing =
|
||||
var webSocketRouting =
|
||||
WsRouting.builder()
|
||||
.endpoint(
|
||||
"*",
|
||||
@ -150,7 +152,14 @@ final class WebSocket implements Polyfill, ProxyExecutable {
|
||||
return connection;
|
||||
});
|
||||
|
||||
yield WebServer.builder().host(host).port(port).addRouting(routing).build();
|
||||
var httpRouting = HttpRouting.builder().route(Method.GET, "_health", () -> "OK");
|
||||
|
||||
yield WebServer.builder()
|
||||
.host(host)
|
||||
.port(port)
|
||||
.addRouting(webSocketRouting)
|
||||
.addRouting(httpRouting)
|
||||
.build();
|
||||
}
|
||||
|
||||
case WEB_SOCKET_SERVER_START -> {
|
||||
|
@ -3,6 +3,9 @@ package org.enso.ydoc;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.helidon.common.buffers.BufferData;
|
||||
import io.helidon.http.Status;
|
||||
import io.helidon.webclient.api.HttpClientResponse;
|
||||
import io.helidon.webclient.api.WebClient;
|
||||
import io.helidon.webclient.websocket.WsClient;
|
||||
import io.helidon.webserver.WebServer;
|
||||
import io.helidon.webserver.websocket.WsRouting;
|
||||
@ -35,6 +38,7 @@ public class YdocTest {
|
||||
|
||||
private static final int WEB_SERVER_PORT = 44556;
|
||||
private static final String YDOC_URL = "ws://localhost:1234/project/";
|
||||
private static final String HEALTHCHECK_URL = "http://localhost:1234/_health";
|
||||
private static final String WEB_SERVER_URL = "ws://127.0.0.1:" + WEB_SERVER_PORT;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(YdocTest.class);
|
||||
@ -94,6 +98,10 @@ public class YdocTest {
|
||||
|
||||
var ok2 = queue.take();
|
||||
Assert.assertTrue(ok2.debugDataHex(), BufferDataUtil.isOk(ok2));
|
||||
|
||||
WebClient http = WebClient.create();
|
||||
HttpClientResponse healthcheckResponse = http.get(HEALTHCHECK_URL).request();
|
||||
Assert.assertEquals(Status.OK_200, healthcheckResponse.status());
|
||||
}
|
||||
|
||||
private static final class BufferDataUtil {
|
||||
|
Loading…
Reference in New Issue
Block a user