integration tests
This commit is contained in:
54
core/health/ports/HealthCheckQuery.ts
Normal file
54
core/health/ports/HealthCheckQuery.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
Reference in New Issue
Block a user