28 lines
812 B
Python
28 lines
812 B
Python
from my_modules.decoratory.header import format_response, feature_flag_required
|
|
from my_modules.app.setup import LIMITER
|
|
from my_modules.app.logger import logger
|
|
|
|
from quart import Blueprint, current_app
|
|
|
|
health_bp = Blueprint("health", __name__)
|
|
|
|
@health_bp.route("/convex", methods=["GET"])
|
|
@LIMITER.limit("30 per minute")
|
|
@feature_flag_required("convex_health", fallback=False, status_code=404)
|
|
@format_response
|
|
async def get_convex_health_for_api():
|
|
runtime = getattr(current_app, "convex_runtime", None)
|
|
if runtime is None:
|
|
return {
|
|
"status": "unavailable",
|
|
"description": "Convex runtime is not attached to app",
|
|
}, 503
|
|
|
|
is_alive = await runtime.is_alive()
|
|
metrics = runtime.get_metrics()
|
|
|
|
return {
|
|
"alive": is_alive,
|
|
"metrics": metrics,
|
|
}, 200 if is_alive else 503
|