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 { ClientConfig } from '../../types/configs.ts'; /** * Client component: generates traffic and handles retry logic. * * Supports four traffic patterns (open-loop, closed-loop, ramping, burst) * and four retry strategies (none, fixed-n, token-bucket, circuit-breaker). * * Validates: Requirements 3.1, 3.2, 3.3, 3.4, 3.5, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 10.1 */ export declare class Client implements SimComponent { readonly id: string; readonly type = ComponentType.CLIENT; readonly config: ComponentConfig; private clientConfig; private inFlightCount; private tokenBucketTokens; private circuitBreakerWindow; private completedCount; private failedCount; private retriedCount; private timedOutCount; private pendingWorkUnits; private resolvedWorkUnits; private started; constructor(id: string, clientConfig: ClientConfig); /** * Generate initial events to kick off traffic generation. * Called when the simulation starts. Schedules the first arrival(s) * at this client based on the traffic pattern. */ generateInitialEvents(context: SimContext): SimEvent[]; /** * Handle an incoming event. * * 'arrival' at self: generate a work unit and send it downstream, then * schedule the next self-arrival based on traffic pattern. * 'departure' at self: response from downstream — record latency, handle * retry logic, and for closed-loop generate next request. */ handleEvent(event: SimEvent, context: SimContext): SimEvent[]; /** * Resolve the downstream target component ID. * Uses the explicit targetComponentId if set, otherwise the first downstream connection. */ private getTargetId; /** * Handle a "generate traffic" arrival at this client. * Creates a new WorkUnit and sends it to the target component. * Schedules the next self-arrival based on traffic pattern. */ private handleGenerateTraffic; /** * Handle a response (departure) coming back from downstream. * Records latency, applies retry strategy on failure, and for * closed-loop generates the next request. */ private handleResponse; /** * Handle a timeout event for an in-flight work unit. * If the work unit is still pending, treat it as a failure and apply retry logic. */ private handleTimeout; /** * Apply the configured retry strategy to a failed work unit. * Returns events to schedule if a retry should happen, empty array otherwise. */ private applyRetryStrategy; /** * Create retry events: send the work unit downstream again and schedule a timeout. */ private createRetryEvents; /** * Prune circuit-breaker sliding window entries older than windowSize. */ private pruneCircuitBreakerWindow; /** * Get the current failure rate from the circuit-breaker sliding window. */ private getCircuitBreakerFailureRate; /** * Create a self-arrival event (trigger to generate traffic). */ private createSelfArrival; /** * Create a new WorkUnit originating from this client. */ private createWorkUnit; /** * Sample from an exponential distribution using the context's seeded PRNG. * Returns -mean * ln(1 - U) where U is uniform [0, 1). */ private exponentialSample; /** * Compute the current arrival rate for an open-loop pattern with optional ramp-up. */ private getOpenLoopRate; /** * Compute the current arrival rate for a ramping traffic pattern * via linear interpolation between startRate and endRate. */ private getRampingRate; /** Return current metrics snapshot */ getMetrics(): ComponentMetrics; /** Reset component to initial state */ reset(): void; } //# sourceMappingURL=client.d.ts.map