Skip to content

Commit c2dbcd6

Browse files
committedDec 6, 2024
Use /_health instead of /_ping
1 parent 55a4f5d commit c2dbcd6

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed
 

‎src/server.zig

+6-6
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ pub fn run(allocator: std.mem.Allocator, indexes: *MultiIndex, address: []const
7373

7474
// Monitoring API
7575
router.get("/_metrics", handleMetrics);
76-
router.get("/_ping", handlePing);
77-
router.get("/:index/_ping", handlePingIndex);
76+
router.get("/_health", handleHealth);
77+
router.get("/:index/_health", handleIndexHealth);
7878

7979
// Search API
8080
router.post("/:index/_search", handleSearch);
@@ -458,18 +458,18 @@ fn handleHeadIndex(ctx: *Context, req: *httpz.Request, res: *httpz.Response) !vo
458458
defer releaseIndex(ctx, index);
459459
}
460460

461-
fn handlePingIndex(ctx: *Context, req: *httpz.Request, res: *httpz.Response) !void {
461+
fn handleIndexHealth(ctx: *Context, req: *httpz.Request, res: *httpz.Response) !void {
462462
const index = try getIndex(ctx, req, res, false) orelse return;
463463
defer releaseIndex(ctx, index);
464464

465-
try handlePing(ctx, req, res);
465+
try res.writer().writeAll("OK\n");
466466
}
467467

468-
fn handlePing(ctx: *Context, req: *httpz.Request, res: *httpz.Response) !void {
468+
fn handleHealth(ctx: *Context, req: *httpz.Request, res: *httpz.Response) !void {
469469
_ = ctx;
470470
_ = req;
471471

472-
try res.writer().writeAll("pong\n");
472+
try res.writer().writeAll("OK\n");
473473
}
474474

475475
fn handleMetrics(ctx: *Context, req: *httpz.Request, res: *httpz.Response) !void {

‎tests/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def wait_for_ready(self, index_name=None, timeout=10.0):
6161
deadline = time.time() + timeout
6262
while True:
6363
if index_name:
64-
url = f'http://localhost:{self.port}/{index_name}/_ping'
64+
url = f'http://localhost:{self.port}/{index_name}/_health'
6565
else:
66-
url = f'http://localhost:{self.port}/_ping'
66+
url = f'http://localhost:{self.port}/_health'
6767
try:
6868
with requests.get(url) as res:
6969
res.raise_for_status()

‎tests/test_index_api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def test_get_index(client, index_name, create_index, fmt):
3333
req = client.get(f'/{index_name}', headers=headers(fmt))
3434
assert req.status_code == 200, req.content
3535
if fmt == 'json':
36-
expected = {'version': 1, 'attributes': {'foo': 1234}}
36+
expected = {'version': 1, 'attributes': {'foo': 1234}}
3737
else:
38-
expected = {'v': 1, 'a': {'foo': 1234}}
38+
expected = {'v': 1, 'a': {'foo': 1234}}
3939
assert decode(fmt, req.content) == expected
4040

4141

‎tests/test_misc.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
def test_ping(client):
2-
req = client.get(f'/_ping')
1+
def test_health(client):
2+
req = client.get('/_health')
33
assert req.status_code == 200, req.content
4-
assert 'pong' in req.text
54

65

7-
def test_index_ping(client, index_name, create_index):
8-
req = client.get(f'{index_name}/_ping')
6+
def test_index_health(client, create_index, index_name):
7+
req = client.get(f'/{index_name}/_health')
98
assert req.status_code == 200, req.content
10-
assert 'pong' in req.text
119

1210

1311
def test_metrics(client):
14-
req = client.get(f'/_metrics')
12+
req = client.get('/_metrics')
1513
assert req.status_code == 200, req.content
1614
assert 'aindex_searches_total' in req.text
17-

0 commit comments

Comments
 (0)
Failed to load comments.