readiness_check

Function readiness_check 

Source
pub async fn readiness_check(pool: Data<SharedPool>) -> impl Responder
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: 8080
  initialDelaySeconds: 5
  periodSeconds: 10

§Usage in App

App::new()
    .app_data(web::Data::new(pool.clone()))
    .route("/ready", web::get().to(readiness_check))