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 { ThrottleConfig } from '../../types/configs.ts'; /** * Throttle component: fast-rejects requests based on admission control. * * Two modes: * - **concurrency**: reject when in-flight count exceeds maxConcurrency * - **rps**: reject when EWMA of arrival rate exceeds maxRps * * Unlike a Queue, the throttle has no buffer — excess arrivals are immediately * returned as failures. Place between a load balancer and a server to enforce * admission control without queueing delay. */ export declare class Throttle implements SimComponent { readonly id: string; readonly type = ComponentType.THROTTLE; readonly config: ComponentConfig; private throttleConfig; private inFlightCount; private pendingOrigins; private ewmaRate; private lastArrivalTime; private totalAdmitted; private totalRejected; constructor(id: string, throttleConfig: ThrottleConfig); handleEvent(event: SimEvent, context: SimContext): SimEvent[]; private shouldReject; /** * Compute the EWMA arrival rate. On each arrival, we update the estimate * using the time since the last arrival as an instantaneous rate sample. * The half-life controls how quickly old samples decay. */ private getEwmaRate; private handleArrival; private handleDeparture; getMetrics(): ComponentMetrics; reset(): void; } //# sourceMappingURL=throttle.d.ts.map