Ë
    KµCjç  ã                   óÔ   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ  e«       Z e«       Zej                  d«      d	efd
„«       Zej                  d«      d	efd„«       Zy)u@  
Health check endpoints.

Two distinct checks, both standard practice in production:
- /health/live  â€” "is the process alive at all". Used by systemd/Docker
  to decide whether to restart the process. Must be cheap and never
  depend on external services (DB/Redis) â€” if Postgres is briefly down,
  the process itself is still alive and should NOT be restarted for that.
- /health/ready â€” "is this instance able to actually serve requests".
  Used by Nginx/load balancer to decide whether to route traffic here.
  Checks DB and Redis connectivity and model load status.
é    )Ú	APIRouter)Úget_settings)Úcheck_db_connection)Úmodel_registry)Úcache_service)Úreference_dataz/health/liveÚreturnc               ƒ   ó0   K  — dt         j                  dœS ­w)NÚalive)ÚstatusÚversion)ÚsettingsÚAPP_VERSION© ó    úHC:\Crop_Prediction\Backend\crop-ai-system\app\api\v1\endpoints\health.pyÚlivenessr      s   è ø€ à¬(×*>Ñ*>Ñ?Ð?ùs   ‚z/health/readyc               ƒ   ó(  K  — t        «       ƒ d {  –—† } t        j                  «       ƒ d {  –—† }t        j                  }t
        j                  }| xr |xr |}|rdnd| rdnd|rdnd|rdnd|rdnddœ|rt        j                  dœS g dœS 7 Œ}7 Œc­w)NÚreadyÚ	not_readyÚokÚfailedÚdegraded)ÚdatabaseÚredis_cacheÚmodels_loadedÚreference_data_loaded)r   ÚchecksÚloaded_models)r   r   Úhealth_checkr   Úis_readyr   Ú_loadedÚloaded_model_keys)Údb_okÚredis_okÚ	models_okÚreference_okÚall_oks        r   Ú	readinessr)      s£   è ø€ ä%Ó'×'€EÜ"×/Ñ/Ó1×1€HÜ×'Ñ'€IÜ!×)Ñ)€LàÒ1�yÒ1 \€Fñ $‘'¨á %™¨8Ù#+™4°Ù%.™T°HÙ-9¡T¸xñ	
ñ >Gœ×9Ñ9ñ	ð 	ð MOñ	ð 	ð (øØ1ús    ‚B�B‘B¬B­A"BÂBN)Ú__doc__Úfastapir   Úapp.core.configr   Úapp.db.sessionr   Úapp.models_loader.registryr   Úapp.services.cache_servicer   Úapp.services.reference_datar   Úrouterr   ÚgetÚdictr   r)   r   r   r   ú<module>r4      sw   ðñõ å (Ý .Ý 5Ý 4Ý 6á	‹€Ù‹>€ð ‡�ˆNÓð@˜ò @ó ð@ð ‡�ˆOÓð˜ò ó ñr   