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

Add an endpoint for health checks #7

Merged
merged 1 commit into from
Jul 14, 2020
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
12 changes: 12 additions & 0 deletions swift_upload_runner/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,15 @@ async def handle_get_container(
await download.a_write_to_response(resp)

return resp


async def handle_health_check(
request: aiohttp.web.Request
) -> aiohttp.web.Response:
"""Answer a service health check."""
# Case degraded

# Case nominal
return aiohttp.web.json_response({
"status": "Ok",
})
5 changes: 5 additions & 0 deletions swift_upload_runner/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .auth import handle_login, read_in_keys, handle_validate_authentication
from .api import handle_get_object, handle_get_container
from .api import handle_post_object_chunk, handle_post_object_options
from .api import handle_health_check


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

app.add_routes([
aiohttp.web.get("/health", handle_health_check)
])

# Add api routes
app.add_routes([
aiohttp.web.get("/{project}/{container}/{object_name:.*}",
Expand Down