Add helper functions for HealthCheck
This commit is contained in:
parent
ca35ae5e24
commit
4742dd9c34
48
helpers/healthcheck_helpers.py
Normal file
48
helpers/healthcheck_helpers.py
Normal file
@ -0,0 +1,48 @@
|
||||
from fastapi import APIRouter, status
|
||||
from datetime import datetime
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/api/health", status_code=status.HTTP_200_OK)
|
||||
def health_check():
|
||||
"""
|
||||
Health check endpoint to verify service status.
|
||||
|
||||
Returns:
|
||||
dict: JSON response indicating service is running.
|
||||
"""
|
||||
response = {
|
||||
"status": "ok",
|
||||
"message": "Service is running",
|
||||
"timestamp": datetime.utcnow().isoformat()
|
||||
}
|
||||
return response
|
||||
|
||||
def is_service_running() -> bool:
|
||||
"""
|
||||
Check if the service is running.
|
||||
|
||||
Returns:
|
||||
bool: True if the service is running, False otherwise.
|
||||
"""
|
||||
# Add any necessary checks or logic here
|
||||
return True
|
||||
|
||||
def get_service_uptime() -> float:
|
||||
"""
|
||||
Get the service uptime in seconds.
|
||||
|
||||
Returns:
|
||||
float: Service uptime in seconds.
|
||||
"""
|
||||
# Add logic to calculate service uptime
|
||||
return 3600.0 # Example: 1 hour uptime
|
||||
|
||||
def get_service_version() -> str:
|
||||
"""
|
||||
Get the current service version.
|
||||
|
||||
Returns:
|
||||
str: Service version string.
|
||||
"""
|
||||
return "1.0.0" # Example version
|
Loading…
x
Reference in New Issue
Block a user