Overview
The/ready endpoint provides a comprehensive readiness check that validates both the Permission Mongo server and its external dependencies (MongoDB, Redis). This endpoint is essential for Kubernetes readiness probes and ensuring the service is fully operational before routing traffic.
Endpoint
Authentication
No authentication required. This endpoint is publicly accessible.Request
No request parameters or body required.Example Request
Response
Success Response (200 OK)
Returns when the server and all required dependencies are operational.Failure Response (503 Service Unavailable)
Returns when one or more dependencies are unavailable.Response Fields
| Field | Type | Description |
|---|---|---|
data.status | string | Overall readiness status: "ready" or "not_ready" |
data.checks | object | Individual health checks for each dependency |
data.checks.mongodb | string | MongoDB connection status: "ok", "unavailable", or "not_configured" |
data.checks.redis | string | Redis/cache connection status: "ok" or "not_configured" |
data.goroutines | integer | Number of active goroutines in the server process |
meta.request_id | string | Unique identifier for the request |
Status Codes
| Status Code | Description |
|---|---|
200 OK | Service is ready and all dependencies are operational |
503 Service Unavailable | Service is not ready or dependencies are unavailable |
Dependency Checks
MongoDB
The MongoDB check validates the connection to the primary datastore:ok: MongoDB is connected and operationalunavailable: MongoDB connection failed or is disconnectednot_configured: MongoDB store handler is not configured
Redis (Cache)
The Redis check validates the optional cache layer:ok: Redis cache is configured and assumed operationalnot_configured: Redis cache is not configured (optional, does not fail readiness)
Implementation Details
The readiness endpoint:- Checks
Store.IsConnected()for MongoDB status - Verifies cache handler existence for Redis status
- Returns HTTP 503 if MongoDB is unavailable or not configured
- Returns HTTP 200 only when all required dependencies are healthy
- Bypassed by authentication middleware for fast health checks
Source Code Reference
Implementation:~/workspace/source/pkg/api/server.go:419
Use Cases
- Kubernetes Readiness Probes: Prevent traffic routing to unhealthy pods
- Zero-Downtime Deployments: Ensure new instances are fully ready before serving requests
- Dependency Monitoring: Verify external service connectivity
- Pre-flight Checks: Validate service state before critical operations
Best Practices
- Use in Readiness Probes: Configure Kubernetes readiness probes to use this endpoint, not
/health - Set Appropriate Timeouts: Allow sufficient time for dependency checks to complete
- Monitor 503 Responses: Alert when readiness checks consistently fail
- Combine with Liveness: Use
/healthfor liveness and/readyfor readiness probes
Related Endpoints
- GET /health - Simple health check without dependency validation
- GET /metrics - Prometheus metrics for detailed monitoring