export interface RetryOptions {
retries: number;
baseMs: number;
maxMs: number;
signal?: AbortSignal;
onRetry?: (attempt: number, delay: number, err: unknown) => void;
import React from "react";
type FallbackProps = {
error: Error;
reset: () => void;
};
class FeatureFlag < ApplicationRecord
validates :key, presence: true, uniqueness: true
validates :percentage, inclusion: { in: 0..100 }
after_commit :expire_cache
require "faraday"
require "faraday/retry"
module Http
class RetryableError < StandardError; end
class CircuitOpenError < StandardError; end
class CircuitBreaker
class CircuitOpenError < StandardError; end
INCREMENT = <<~LUA.freeze
local n = redis.call('INCR', KEYS[1])
if n == 1 then redis.call('EXPIRE', KEYS[1], ARGV[1]) end
export type CircuitState = "closed" | "open" | "half-open";
export interface CircuitBreakerOptions {
failureThreshold: number;
resetTimeout: number; // ms to wait in "open" before probing
onStateChange?: (from: CircuitState, to: CircuitState) => void;
import { ApplicationConfig } from '@angular/core';
import {
provideHttpClient,
withInterceptors,
} from '@angular/common/http';
import { retryInterceptor } from './retry.interceptor';
package com.example.ratelimit;
public class TokenBucket {
private final long capacity;
private final long refillTokens;
import time
from dataclasses import dataclass
from typing import Optional
import requests
package com.example.fx.config;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.caffeine.CaffeineCacheManager;
package com.example.rates.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.web.client.RestTemplate;
<?php
namespace App\Message;
final class SyncCustomerMessage
{