@felixgeelhaar/govee-api-client
Version:
Enterprise-grade TypeScript client library for the Govee Developer REST API
133 lines • 4.7 kB
TypeScript
/**
* Integration Guide for Retry Logic with Govee API Client
*
* This file provides comprehensive examples and integration patterns for
* adding retry logic to the Govee API client after rate limiting is implemented.
*/
import { Logger } from 'pino';
import { GoveeControlService } from '../../services/GoveeControlService';
import { RetryPolicy, RetryableRepository } from './index';
/**
* INTEGRATION EXAMPLE 1: Basic Retry-Enabled Repository
*
* This example shows how to wrap the existing GoveeDeviceRepository
* with retry functionality using default Govee API optimized settings.
*/
export declare function createBasicRetryRepository(apiKey: string, logger?: Logger): RetryableRepository;
/**
* INTEGRATION EXAMPLE 2: Production-Ready Service with Retry Logic
*
* This example shows how to integrate retry logic into the GoveeControlService
* for production environments with conservative retry policies.
*/
export declare function createProductionGoveeService(apiKey: string, logger: Logger): GoveeControlService;
/**
* INTEGRATION EXAMPLE 3: Custom Retry Configuration for Specific Use Cases
*
* This example demonstrates creating custom retry policies for different
* operational scenarios.
*/
export declare class CustomRetryConfigurations {
/**
* Configuration for bulk operations that need to be resilient
*/
static createBulkOperationConfig(logger?: Logger): RetryPolicy;
/**
* Configuration for real-time operations that need fast failure
*/
static createRealTimeConfig(logger?: Logger): RetryPolicy;
/**
* Configuration optimized for rate-limited APIs
*/
static createRateLimitOptimizedConfig(logger?: Logger): RetryPolicy;
}
/**
* INTEGRATION EXAMPLE 4: Service with Multiple Retry Strategies
*
* This example shows how to use different retry strategies for different
* types of operations within the same service.
*/
export declare class AdvancedGoveeService {
private readonly bulkRepository;
private readonly realTimeRepository;
private readonly baseRepository;
private readonly logger;
constructor(apiKey: string, logger: Logger);
/**
* Bulk device discovery with resilient retry logic
*/
discoverAllDevices(): Promise<import("../..").GoveeDevice[]>;
/**
* Real-time device state check with fast failure
*/
getDeviceStateRealTime(deviceId: string, sku: string): Promise<import("../..").DeviceState>;
/**
* Get comprehensive retry metrics across all strategies
*/
getRetryMetrics(): {
bulk: Readonly<import("./RetryPolicy").RetryMetrics>;
realTime: Readonly<import("./RetryPolicy").RetryMetrics>;
};
/**
* Reset all retry metrics
*/
resetMetrics(): void;
}
/**
* INTEGRATION EXAMPLE 5: Monitoring and Observability Integration
*
* This example shows how to integrate retry metrics with monitoring systems.
*/
export declare class RetryMetricsCollector {
private readonly retryableRepository;
private readonly logger;
private readonly metricsIntervalMs;
private metricsInterval?;
constructor(retryableRepository: RetryableRepository, logger: Logger, metricsIntervalMs?: number);
/**
* Start collecting and logging retry metrics
*/
startMetricsCollection(): void;
/**
* Stop metrics collection
*/
stopMetricsCollection(): void;
/**
* Get current metrics snapshot
*/
getMetricsSnapshot(): {
timestamp: string;
total_attempts: number;
successful_retries: number;
failed_retries: number;
success_rate: number;
average_retry_delay_ms: number;
circuit_breaker_state: "closed" | "open" | "half-open";
last_error: {
name: string;
code: string;
message: string;
timestamp: string;
stack?: string;
cause?: unknown;
} | undefined;
last_retry: string | undefined;
};
}
/**
* INTEGRATION EXAMPLE 6: Environment-Specific Configuration Factory
*
* This factory creates appropriate retry configurations based on environment.
*/
export declare class RetryConfigFactory {
/**
* Create retry configuration based on environment
*/
static createForEnvironment(environment: 'development' | 'testing' | 'staging' | 'production', logger?: Logger): RetryPolicy;
/**
* Create retry configuration for specific use cases
*/
static createForUseCase(useCase: 'bulk' | 'realtime' | 'background' | 'interactive', logger?: Logger): RetryPolicy;
}
export { RetryExecutorFactory } from './RetryableRequest';
//# sourceMappingURL=IntegrationGuide.d.ts.map