readiness_check

Function readiness_check 

Source
pub fn readiness_check(
    pool: &State<SharedPool>,
) -> Result<Json<Value>, ErrorResponder>
Expand description

Readiness check endpoint.

Returns 200 OK if the pool has capacity to handle requests, 503 Service Unavailable otherwise.

Unlike health_check, this actually checks the pool state.

§Endpoint

GET /ready

§Response

§Ready (200 OK)

{
    "status": "ready"
}

§Not Ready (503 Service Unavailable)

{
    "status": "not_ready",
    "reason": "no_available_capacity"
}

§Readiness Criteria

The service is “ready” if either:

  • There are idle browsers available (available > 0), OR
  • There is capacity to create new browsers (active < max_pool_size)

§Use Cases

  • Kubernetes readiness probe
  • Load balancer health check (remove from rotation when busy)
  • Auto-scaling triggers

§Kubernetes Example

readinessProbe:
  httpGet:
    path: /ready
    port: 8000
  initialDelaySeconds: 5
  periodSeconds: 10

§Usage in App

rocket::build()
    .manage(pool)
    .mount("/", routes![readiness_check])