defect-inspection-tools-mcp-server
Version:
Defect inspection tools server handling defect detection, analysis, and reporting with AI/ML capabilities for quality control
60 lines (59 loc) • 1.87 kB
TypeScript
import { ErrorContext } from '../middleware/error-handler.js';
export interface ServiceConfig {
timeout?: number;
retries?: number;
retryDelay?: number;
circuitBreakerThreshold?: number;
circuitBreakerTimeout?: number;
}
export interface ServiceMetrics {
totalRequests: number;
successCount: number;
errorCount: number;
averageResponseTime: number;
circuitBreakerState: CircuitBreakerState;
lastError?: Date;
}
export interface ServiceResponse<T> {
success: boolean;
data?: T;
error?: string;
metadata?: {
responseTime: number;
retryCount: number;
timestamp: Date;
};
}
export declare enum CircuitBreakerState {
CLOSED = "CLOSED",
OPEN = "OPEN",
HALF_OPEN = "HALF_OPEN"
}
export declare enum ServiceHealthStatus {
HEALTHY = "HEALTHY",
DEGRADED = "DEGRADED",
UNHEALTHY = "UNHEALTHY"
}
export declare abstract class BaseService {
protected config: Required<ServiceConfig>;
protected metrics: ServiceMetrics;
protected circuitBreakerState: CircuitBreakerState;
protected circuitBreakerOpenTime?: Date;
protected responseTimes: number[];
protected serviceName: string;
constructor(serviceName: string, config?: ServiceConfig);
abstract healthCheck(): Promise<ServiceHealthStatus>;
protected executeWithResilience<T>(operation: () => Promise<T>, context: ErrorContext): Promise<ServiceResponse<T>>;
private canExecute;
private checkCircuitBreaker;
private resetCircuitBreaker;
private updateMetrics;
private calculateRetryDelay;
private shouldNotRetry;
getMetrics(): ServiceMetrics;
getHealthStatus(): Promise<ServiceHealthStatus>;
resetMetrics(): void;
getServiceName(): string;
getConfig(): Required<ServiceConfig>;
setCircuitBreakerState(state: CircuitBreakerState): void;
}