Fix typing and minor issues
This commit is contained in:
parent
2db2253578
commit
72ab627a34
54 changed files with 635 additions and 589 deletions
26
great_ai/deploy/routes/bootstrap_meta_endpoints.py
Normal file
26
great_ai/deploy/routes/bootstrap_meta_endpoints.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
from typing import Any
|
||||
|
||||
from fastapi import APIRouter, FastAPI, status
|
||||
|
||||
from ...views import ApiMetadata, CacheStatistics, HealthCheckResponse
|
||||
|
||||
|
||||
def bootstrap_meta_endpoints(app: FastAPI, func: Any, metadata: ApiMetadata) -> None:
|
||||
router = APIRouter(
|
||||
tags=["meta"],
|
||||
)
|
||||
|
||||
@router.get("/health", status_code=status.HTTP_200_OK)
|
||||
def check_health() -> HealthCheckResponse:
|
||||
hits, misses, maxsize, cache_size = func.cache_info()
|
||||
cache_statistics = CacheStatistics(
|
||||
hits=hits, misses=misses, size=cache_size, max_size=maxsize
|
||||
)
|
||||
|
||||
return HealthCheckResponse(is_healthy=True, cache_statistics=cache_statistics)
|
||||
|
||||
@router.get("/version", response_model=ApiMetadata, status_code=status.HTTP_200_OK)
|
||||
def get_version() -> ApiMetadata:
|
||||
return metadata
|
||||
|
||||
app.include_router(router)
|
||||
Loading…
Add table
Add a link
Reference in a new issue