When calling Circuitbox.circuit, you can pass an options hash to override global defaults for that specific service. You can also pass a Proc as an option value to allow dynamic configuration without restarting processes.
Available per-circuit options:
exceptions: (Required) Array of exception classes to track for counting failures.sleep_window: Seconds the circuit stays open once it has passed the error threshold.time_window: Length of interval (in seconds) over which the error rate is calculated.volume_threshold: Number of requests within time_window required before calculating error rates.circuit_store: The store to save circuit state (overrides default_circuit_store). Must be Moneta compatible and support increment.error_threshold: Percentage (0-100) of failures that will open the circuit.notifier: Custom notifier (overrides default_notifier).
Circuitbox.circuit(:your_service, {
exceptions: [YourCustomException],
sleep_window: 300,
time_window: 60,
volume_threshold: 10,
circuit_store: Circuitbox::MemoryStore.new,
error_threshold: 50,
notifier: Notifier.new
})
# Dynamic configuration using a Proc
Circuitbox.circuit(:yammer, {
sleep_window: Proc.new { Configuration.get(:sleep_window) },
exceptions: [Net::ReadTimeout]
})