import type { SimEvent } from '../../types/events.ts'; import { ComponentType } from '../../types/components.ts'; import type { SimComponent, SimContext, ComponentConfig, ComponentMetrics } from '../../types/components.ts'; import type { LoadBalancerConfig } from '../../types/configs.ts'; /** * LoadBalancer component: distributes incoming work units across downstream * components using a configurable strategy (round-robin, random, least-connections). * * Validates: Requirements 8.1, 8.2, 8.3 */ export declare class LoadBalancer implements SimComponent { readonly id: string; readonly type = ComponentType.LOAD_BALANCER; readonly config: ComponentConfig; private lbConfig; private rrIndex; private connectionCounts; private failedDownstream; private errorRate; private workUnitToDownstream; private pendingOrigins; private totalForwarded; private totalFailed; constructor(id: string, lbConfig: LoadBalancerConfig); /** * Process an incoming event. * * 'arrival': Select a downstream component based on strategy, forward the work unit. * 'departure': Forward response back to origin, decrement connection count. */ handleEvent(event: SimEvent, context: SimContext): SimEvent[]; /** * Handle an arrival: select a downstream and forward the work unit. * Excludes failed downstream components (Req 8.2). * Returns failure if all downstream are failed (Req 8.3). */ private handleArrival; /** * Handle a departure from downstream: forward response back to origin, * decrement connection count for least-connections tracking. */ private handleDeparture; /** * Select a downstream component based on the configured strategy (Req 8.1). */ private selectDownstream; /** Round-robin: cycle through available downstream in order */ private selectRoundRobin; /** Random: use context.random() to pick a random downstream */ private selectRandom; /** Least-connections: pick the downstream with the fewest active connections */ private selectLeastConnections; setErrorRate(rate: number): void; /** Mark a downstream component as failed (Req 8.2) */ setDownstreamFailed(componentId: string, failed: boolean): void; /** Return current metrics snapshot */ getMetrics(): ComponentMetrics; /** Reset component to initial state */ reset(): void; } //# sourceMappingURL=load-balancer.d.ts.map