failover-sdk
Version:
One-line API failover with zero downtime. Native Rust performance with TypeScript interface.
58 lines (55 loc) • 2.75 kB
TypeScript
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export declare function initMetrics(): void
export declare function exportPrometheusMetrics(): string
export declare function getMetricsSummary(): string
export declare function incRequestMetric(provider: string, method: string, status: string): void
export declare function observeRequestDurationMetric(provider: string, method: string, durationSecs: number): void
export declare function setCircuitBreakerStateMetric(provider: string, state: string): void
export declare function incFailoverMetric(fromProvider: string, toProvider: string, reason: string): void
export declare function setProviderHealthScoreMetric(provider: string, score: number): void
export declare function incConfigReloadMetric(): void
export declare function incProviderErrorMetric(provider: string, errorType: string): void
export interface FallbackRequest {
service: string
operation: string
method: string
url: string
headers: Record<string, string>
body?: string
}
export interface FallbackResponse {
status: number
headers: Record<string, string>
body: string
providerUsed: string
attemptCount: number
totalDurationMs: number
debugInfo?: DebugInfo
normalized?: string
}
export interface DebugInfo {
failoverTriggered: boolean
failedProviders: Array<string>
retryAttempts: number
}
export declare function fallback(req: FallbackRequest): Promise<FallbackResponse>
/** Get circuit breaker statistics for a specific provider */
export declare function getCircuitBreakerStats(provider: string): string | null
/** Get circuit breaker statistics for all providers */
export declare function getAllCircuitBreakerStats(): string
/** Get health score for a specific provider (0.0 = unhealthy, 1.0 = healthy) */
export declare function getProviderHealthScore(provider: string): number
/** Reset circuit breaker for a specific provider */
export declare function resetCircuitBreaker(provider: string): void
/** Manually trip the circuit breaker for a specific provider */
export declare function tripCircuitBreaker(provider: string): void
/** Classify an HTTP error response */
export declare function classifyHttpError(statusCode: number, errorMessage: string, provider: string, service: string, operation: string, responseHeaders?: string | undefined | null): string
/** Classify a network error */
export declare function classifyNetworkError(errorMessage: string, provider: string, service: string, operation: string): string
/** Get error patterns for a provider */
export declare function getErrorPatterns(provider: string, timeWindowSeconds: number): string
/** Get comprehensive error analytics summary */
export declare function getErrorAnalyticsSummary(): string