* Async chalice.core.tenants:tenants_exists, and propagate * rework after review * typofix * fix(chalice): small fixes * fix(api): use a global variable to store singletong... ... that will not work if several POSIX threads are serving from the same POSIX processus. * fix(api): pass database argument as dictionary. ref: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING * chore(api): ease debugging with simple return statement. * NOTES++ --------- Co-authored-by: Taha Yassine Kraiem <tahayk2@gmail.com>
23 lines
776 B
Python
23 lines
776 B
Python
from fastapi import Depends
|
|
from fastapi import HTTPException, status
|
|
|
|
import schemas
|
|
from chalicelib.core import health, tenants
|
|
from or_dependencies import OR_context
|
|
from routers.base import get_routers
|
|
|
|
public_app, app, app_apikey = get_routers()
|
|
|
|
|
|
@app.get('/healthz', tags=["health-check"])
|
|
def get_global_health_status(context: schemas.CurrentContext = Depends(OR_context)):
|
|
return {"data": health.get_health(tenant_id=context.tenant_id)}
|
|
|
|
|
|
if not tenants.tenants_exists(use_pool=False):
|
|
@public_app.get('/health', tags=["health-check"])
|
|
async def get_public_health_status():
|
|
if await tenants.tenants_exists():
|
|
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"Not Found")
|
|
|
|
return {"data": health.get_health()}
|