/** * Adaptive Concurrency Controller * * Automatically adjusts `maxConcurrent` based on: * - Rate limit (429) errors → decrease concurrency * - Sustained successful requests → increase concurrency * * This provides automatic backpressure without manual tuning. */ import type { FleetBus } from './fleet-bus.js'; import type { AdaptiveConcurrencyConfig } from '../types/config.js'; import type { Logger } from '../types/logger.js'; export interface AdaptiveConcurrencyState { current: number; min: number; max: number; consecutiveSuccesses: number; consecutiveFailures: number; totalDecreases: number; totalIncreases: number; enabled: boolean; } /** * Adaptive Concurrency Controller * * Monitors fleet events for rate-limit (429) errors and adjusts concurrency * automatically to prevent overwhelming the API provider. */ export declare class AdaptiveConcurrencyController { private readonly config; private state; private readonly disposers; private stateChangeHandlers; private readonly logger; constructor(fleetBus: FleetBus, setMaxConcurrent: (n: number) => void, config?: Partial, onStateChange?: (state: AdaptiveConcurrencyState) => void, logger?: Pick); private setupEventHandlers; /** * Handle a rate limit (429) error - decrease concurrency */ private handleRateLimit; /** * Force a decrease (e.g., manual trigger or other error types) */ decrease(target?: number): void; /** * Get the current state */ getState(): AdaptiveConcurrencyState; /** * Update configuration at runtime */ updateConfig(config: Partial): void; /** * Dispose of the controller and clean up event listeners */ dispose(): void; private notifyStateChange; /** * Register a state change handler */ onStateChange(handler: (state: AdaptiveConcurrencyState) => void): () => void; } //# sourceMappingURL=adaptive-concurrency.d.ts.map