European Parliament MCP Server API - v1.0.1
    Preparing search index...

    Health Check Service

    Aggregates status from the rate limiter and metrics service to produce a structured HealthStatus snapshot.

    The check is intentionally synchronous-safe – it never makes network calls. Network reachability is inferred from recent metrics (EP API error rate).

    const healthService = new HealthService(rateLimiter, metricsService);
    const status = healthService.checkHealth();
    console.log(status.status); // 'healthy' | 'degraded' | 'unhealthy'
    Index

    Constructors

    Properties

    metricsService: MetricsService

    Metrics service providing EP API call and error counters used to infer reachability

    rateLimiter: RateLimiter

    Rate limiter whose token availability is checked as part of the degraded-state heuristic

    startTime: number

    Methods

    • Produces a health status snapshot.

      Checks:

      1. Rate-limiter token availability (degraded if < 10 %)
      2. EP API error counter (unhealthy if recent errors > 0 with no successes)

      The check is synchronous-safe — it never makes network calls. Reachability is inferred from cached metric counters.

      Returns HealthStatus

      Structured HealthStatus object with status, epApiReachable, cache, rateLimiter, timestamp, and uptimeMs

      If the underlying metrics or rate-limiter service throws unexpectedly (should not occur under normal operating conditions)

      const healthService = new HealthService(rateLimiter, metricsService);
      const status = healthService.checkHealth();
      if (status.status !== 'healthy') {
      console.warn('Server degraded:', status);
      }

      0.8.0

    • Determine EP API reachability from recorded metrics. Cyclomatic complexity: 2

      Returns null when no API calls have been recorded yet (unknown state), false when all calls failed (error count >= call count > 0), true when at least some calls succeeded.

      Returns boolean | null