/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
export interface IThrottler {
    /**
     * Computes what the throttle delay should be, and records an attempt
     * which will be used for calculating future attempt delays.
     */
    getDelay(): number;
    /**
     * Number of attempts that occurred within the sliding window as of
     * the most recent delay computation.
     */
    readonly numAttempts: number;
    /**
     * Width of sliding delay window in milliseconds.
     */
    readonly delayWindowMs: number;
    /**
     * Maximum delay allowed in milliseconds.
     */
    readonly maxDelayMs: number;
    /**
     * Delay function used to calculate what the delay should be.
     * The input is the number of attempts that occurred within the sliding window.
     * The result is the calculated delay in milliseconds.
     */
    readonly delayFn: (numAttempts: number) => number;
}
/**
 * Used to give increasing delay times for throttling a single functionality.
 * Delay is based on previous attempts within specified time window, subtracting delay time.
 */
export declare class Throttler implements IThrottler {
    /**
     * Width of sliding delay window in milliseconds.
     */
    readonly delayWindowMs: number;
    /**
     * Maximum delay allowed in milliseconds.
     */
    readonly maxDelayMs: number;
    /**
     * Delay function used to calculate what the delay should be.
     * The input is the number of attempts that occurred within the sliding window.
     * The result is the calculated delay in milliseconds.
     */
    readonly delayFn: (numAttempts: number) => number;
    private startTimes;
    get numAttempts(): number;
    /**
     * Gets all attempt start times after compensating for the delay times
     * by adding the delay times to the actual times.
     */
    getAttempts(): readonly number[];
    /**
     * Latest attempt time after compensating for the delay time itself
     * by adding the delay time to the actual time.
     */
    get latestAttemptTime(): number | undefined;
    constructor(
    /**
     * Width of sliding delay window in milliseconds.
     */
    delayWindowMs: number, 
    /**
     * Maximum delay allowed in milliseconds.
     */
    maxDelayMs: number, 
    /**
     * Delay function used to calculate what the delay should be.
     * The input is the number of attempts that occurred within the sliding window.
     * The result is the calculated delay in milliseconds.
     */
    delayFn: (numAttempts: number) => number);
    getDelay(): number;
}
/**
 * Helper function to generate simple exponential throttle functions.
 * f(n) = [coefficient] x ([multiplier]^n) + [flatOffset]
 * where n = number of attempts, and f(n) = delay time in milliseconds.
 * If not provided, coefficient will default to 1, multiplier to 2,
 * minimum delay to 0, and the offset to 0, yielding:
 * 0 ms, 2 ms, 4 ms, 8 ms, ..., 2^n ms
 * where M = multiplier; an exponential back-off.
 * Use initialDelay to decide what should happen when numAttempts is 0,
 * leave it undefined to not special case.
 */
export declare const formExponentialFn: ({ multiplier, coefficient, offset, initialDelay, }?: {
    multiplier?: number | undefined;
    coefficient?: number | undefined;
    offset?: number | undefined;
    initialDelay?: number | undefined;
}) => IThrottler["delayFn"];
/**
 * f(n) = C x (B^(n+A)) + F = (C x B^A) x B^n + F
 */
export declare const formExponentialFnWithAttemptOffset: (attemptOffset: number, { multiplier, coefficient, offset, initialDelay, }?: {
    multiplier?: number | undefined;
    coefficient?: number | undefined;
    offset?: number | undefined;
    initialDelay?: number | undefined;
}) => IThrottler["delayFn"];
/**
 * Helper function to generate simple linear throttle functions.
 * f(n) = [coefficient] x n + [flatOffset]
 * where n = number of attempts, and f(n) = delay time in milliseconds.
 * If not provided, coefficient will default to 1, and offset to 0, yielding:
 * 0 ms, 1 ms, 2 ms, 3 ms, ..., n ms delays; a linear back-off.
 */
export declare const formLinearFn: ({ coefficient, offset }?: {
    coefficient?: number | undefined;
    offset?: number | undefined;
}) => IThrottler["delayFn"];
/**
 * f(n) = C x (n+A) + F = C x n + (C x A + F)
 */
export declare const formLinearFnWithAttemptOffset: (attemptOffset: number, { coefficient, offset }?: {
    coefficient?: number | undefined;
    offset?: number | undefined;
}) => IThrottler["delayFn"];
//# sourceMappingURL=throttler.d.ts.map