Code Explainers

Code explainers tagged #resilience

ruby
require "timeout"
require "net/http"
 
class RemoteInventoryClient

Bounding a slow HTTP call with Timeout in Ruby

timeout error-handling http
Intermediate 6 steps
ruby
class CircuitBreaker
  class OpenCircuitError < StandardError; end
 
  def initialize(failure_threshold: 5, reset_timeout: 30, half_open_max: 1)

How a circuit breaker guards failing calls

state-machine fault-tolerance concurrency
Advanced 9 steps
python
import time
import threading
from enum import Enum
from functools import wraps

Building a circuit breaker in Python

circuit-breaker resilience decorators
Advanced 7 steps
php
<?php
 
namespace App\Resilience;
 

How a circuit breaker guards a flaky service

circuit-breaker resilience caching
Intermediate 9 steps
python
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
 

Building a resilient requests Session

retries backoff http-client
Intermediate 7 steps
php
<?php
 
namespace App\Services;
 

Resilient HTTP retries with Laravel's client

http-client retry-logic error-handling
Intermediate 7 steps
ruby
module Retryable
  class RetriesExhausted < StandardError; end
 
  RETRYABLE_ERRORS = [

Exponential backoff retries in Ruby

retry-logic exponential-backoff error-handling
Intermediate 7 steps