/** Available retry strategy types */ export type RetryStrategyType = 'LINEAR' | 'EXPONENTIAL' | 'FIXED' | 'SINGLE_RETRY' | 'NO_RETRIES'; /** * Conditions can be used to limit when a retry strategy applies. */ export type RetryStrategyCondition = 'NETWORK_ERROR'; /** * Configuration for check and monitor retry behavior. * Defines how and when to retry failed checks or monitors before marking * them as permanently failed. */ export interface RetryStrategy { /** The retry strategy type */ type: RetryStrategyType; /** * The number of seconds to wait before the first retry attempt. * This value is used differently based on the retry strategy type: * - FIXED: Same delay for all retries * - LINEAR: Base value that increases linearly (baseBackoffSeconds * attempt) * - EXPONENTIAL: Base value that increases exponentially (baseBackoffSeconds ^ attempt) * - SINGLE_RETRY: The delay for the first and only retry * * @defaultValue 60 * @example * ```typescript * // Fixed: 30s, 30s, 30s * baseBackoffSeconds: 30 * * // Linear: 10s, 20s, 30s * baseBackoffSeconds: 10 * * // Exponential: 5s, 25s, 125s * baseBackoffSeconds: 5 * * // Single retry: 10s * baseBackoffSeconds: 10 * ``` */ baseBackoffSeconds?: number; /** * The maximum number of attempts to retry the check. * Value must be between 1 and 10. * * @defaultValue 2 */ maxRetries?: number; /** * The total amount of time to continue retrying the check. * Maximum value is 600 seconds (10 minutes). * If retries would exceed this duration, they are stopped early. * * @defaultValue 600 */ maxDurationSeconds?: number; /** * Whether retries should be run in the same region as the initial check run. * If false, retries use a randomly selected region for better fault tolerance. * * @defaultValue true */ sameRegion?: boolean; /** * Apply the retry strategy only if the cause of the failure matches the * given condition. Otherwise, do not retry. * * The following conditions are supported: * - NETWORK_ERROR: Retry only if the failure was caused by a network error. * Available with the {@link ApiCheck} and {@link UrlMonitor} constructs. */ onlyOn?: RetryStrategyCondition; } /** * Options for configuring retry strategy behavior. * These options can be used with any retry strategy type. */ export type RetryStrategyOptions = Omit; /** * Configuration for linear retry strategies. */ export interface LinearRetryStrategy extends RetryStrategy { type: 'LINEAR'; } /** * Options for configuring linear retry strategy behavior. */ export type LinearRetryStrategyOptions = RetryStrategyOptions; /** * Configuration for exponential retry strategies. */ export interface ExponentialRetryStrategy extends RetryStrategy { type: 'EXPONENTIAL'; } /** * Options for configuring exponential retry strategy behavior. */ export type ExponentialRetryStrategyOptions = RetryStrategyOptions; /** * Configuration for fixed retry strategies. */ export interface FixedRetryStrategy extends RetryStrategy { type: 'FIXED'; } /** * Options for configuring fixed retry strategy behavior. */ export type FixedRetryStrategyOptions = RetryStrategyOptions; /** * Configuration for single retry retry strategies. */ export interface SingleRetryRetryStrategy extends Pick { type: 'SINGLE_RETRY'; } /** * Options for configuring single retry retry strategy behavior. */ export type SingleRetryRetryStrategyOptions = Pick; /** * Configuration for no retry retry strategies. */ export interface NoRetriesRetryStrategy extends Pick { type: 'NO_RETRIES'; } /** * Builder class for creating retry strategies. * Provides convenient methods to create different types of retry strategies. * Retry strategies control how and when to retry failed checks before marking them as failed. * * @example * ```typescript * // Fixed retry strategy - same delay between retries (60s, 60s, 60s) * const fixedRetry = RetryStrategyBuilder.fixedStrategy({ * maxRetries: 3, * baseBackoffSeconds: 60, * sameRegion: false * }) * * // Linear retry strategy - increasing delay (10s, 20s, 30s) * const linearRetry = RetryStrategyBuilder.linearStrategy({ * maxRetries: 3, * baseBackoffSeconds: 10, * maxDurationSeconds: 600 * }) * * // Exponential retry strategy - exponential backoff (10s, 100s, 1000s) * const exponentialRetry = RetryStrategyBuilder.exponentialStrategy({ * maxRetries: 3, * baseBackoffSeconds: 10 * }) * * // No retries - fail immediately * const noRetries = RetryStrategyBuilder.noRetries() * * // Retry on network errors only * const retryOnNetworkError = RetryStrategyBuilder.fixedStrategy({ * maxRetries: 1, * baseBackoffSeconds: 30, * sameRegion: false, * onlyOn: 'NETWORK_ERROR' * }) * ``` * * @see {@link https://www.checklyhq.com/docs/alerting-and-retries/retries/ | Retry Strategies Documentation} */ export declare class RetryStrategyBuilder { private static readonly DEFAULT_BASE_BACKOFF_SECONDS; private static readonly DEFAULT_MAX_RETRIES; private static readonly DEFAULT_MAX_DURATION_SECONDS; private static readonly DEFAULT_SAME_REGION; /** * Each retry is run with the same backoff between attempts. */ static fixedStrategy(options?: FixedRetryStrategyOptions): FixedRetryStrategy; /** * The delay between retries increases linearly * * The delay between retries is calculated using `baseBackoffSeconds * attempt`. * For example, retries will be run with a backoff of 10s, 20s, 30s, and so on. */ static linearStrategy(options?: LinearRetryStrategyOptions): LinearRetryStrategy; /** * The delay between retries increases exponentially * * The delay between retries is calculated using `baseBackoffSeconds ^ attempt`. * For example, retries will be run with a backoff of 10s, 100s, 1000s, and so on. */ static exponentialStrategy(options?: ExponentialRetryStrategyOptions): ExponentialRetryStrategy; /** * A single retry will be performed. */ static singleRetry(options?: SingleRetryRetryStrategyOptions): SingleRetryRetryStrategy; /** * No retries are performed. */ static noRetries(): NoRetriesRetryStrategy; private static defaults; }