Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit 9073fb1

Browse files
committed
Add an endpoint for health checks
1 parent faaa1cb commit 9073fb1

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

swift_upload_runner/api.py

+12
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,15 @@ async def handle_get_container(
195195
await download.a_write_to_response(resp)
196196

197197
return resp
198+
199+
200+
async def handle_health_check(
201+
request: aiohttp.web.Request
202+
) -> aiohttp.web.Response:
203+
"""Answer a service health check."""
204+
# Case degraded
205+
206+
# Case nominal
207+
return aiohttp.web.json_response({
208+
"status": "Ok",
209+
})

swift_upload_runner/server.py

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from .auth import handle_login, read_in_keys, handle_validate_authentication
1717
from .api import handle_get_object, handle_get_container
1818
from .api import handle_post_object_chunk, handle_post_object_options
19+
from .api import handle_health_check
1920

2021

2122
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
@@ -48,6 +49,10 @@ async def servinit() -> aiohttp.web.Application:
4849
aiohttp.web.post("/{project}", handle_login)
4950
])
5051

52+
app.add_routes([
53+
aiohttp.web.get("/health", handle_health_check)
54+
])
55+
5156
# Add api routes
5257
app.add_routes([
5358
aiohttp.web.get("/{project}/{container}/{object_name:.*}",

0 commit comments

Comments
 (0)