/**
 * Health Check Query Port
 * 
 * Defines the interface for querying health status.
 * This port is implemented by adapters that can perform health checks.
 */

export interface HealthCheckQuery {
  /**
   * Perform a health check
   */
  performHealthCheck(): Promise<HealthCheckResult>;
  
  /**
   * Get current connection status
   */
  getStatus(): ConnectionStatus;
  
  /**
   * Get detailed health information
   */
  getHealth(): ConnectionHealth;
  
  /**
   * Get reliability percentage
   */
  getReliability(): number;
  
  /**
   * Check if API is currently available
   */
  isAvailable(): boolean;
}

export type ConnectionStatus = 'connected' | 'disconnected' | 'degraded' | 'checking';

export interface ConnectionHealth {
  status: ConnectionStatus;
  lastCheck: Date | null;
  lastSuccess: Date | null;
  lastFailure: Date | null;
  consecutiveFailures: number;
  totalRequests: number;
  successfulRequests: number;
  failedRequests: number;
  averageResponseTime: number;
}

export interface HealthCheckResult {
  healthy: boolean;
  responseTime: number;
  error?: string;
  timestamp: Date;
}
