/** * RateLimitedHttpStep — abstract step with an injectable rate limiter. * * Subclasses provide a `RateLimiterLike` implementation via * `createLimiter()`. This decouples the step from any specific * rate-limiting library. HDRI apps typically use p-limit + p-retry + * cockatiel; external consumers can use any implementation. * * Usage: * class FetchPagesStep extends RateLimitedHttpStep { * protected createLimiter(): RateLimiterLike { * const limit = pLimit(4); * return { * schedule: (fn) => limit(fn), * inFlight: () => limit.activeCount, * queueDepth: () => limit.pendingCount, * }; * } * async run(ctx: MyContext): Promise { * for (const url of ctx.state.urls) { * await this.schedule(() => fetch(url)); * } * } * } */ import { PipelineStep } from "@warpgogol/pipeline-core"; import type { PipelineStepContext } from "@warpgogol/pipeline-core"; /** Minimal rate-limiter contract that any implementation can satisfy. */ export type RateLimiterLike = { schedule(fn: () => Promise): Promise; inFlight(): number; queueDepth(): number; }; export declare abstract class RateLimitedHttpStep extends PipelineStep { #private; /** * Subclass must return a rate-limiter implementation. * Called once per step instance — the result is cached. */ protected abstract createLimiter(): RateLimiterLike; /** * Run `fn` through the step's rate limiter. * All calls share the same limiter instance. */ protected schedule(fn: () => Promise): Promise; /** Current in-flight call count — useful for logs / metrics. */ protected inFlight(): number; /** Current queue depth (calls waiting for the gate). */ protected queueDepth(): number; } //# sourceMappingURL=rate-limited-http-step.d.ts.map