Add override config layer for forced retry behavior#121
Draft
Conversation
Adds Retriable.override and Retriable.reset_override APIs that force retry settings over local call options. Uses a simple hash-based API: Retriable.override(tries: 1, base_interval: 0) Override precedence: override > local options > configure defaults Primary use case is test short-circuiting where tries: 1 must win even when production code passes explicit local options.
…ix version/changelog - Deep-dup and freeze override opts to prevent external mutation - Validate context values are Hash before merging in merged_context_options - Bump VERSION to 3.4.2 and add 3.4.1 section to CHANGELOG - Clarify README per-context override wording (top-level overrides already win) - Add spec coverage for mutation protection and nil context values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
Retriable.overrideandRetriable.reset_overrideAPIs that force retry settings over local call options using a simple hash-based interface.Precedence
Use case
Test short-circuiting: in test environments,
tries: 1must win even when production code passes explicit local options likeRetriable.retriable(tries: 5). Previously,Retriable.configurecould only set defaults that local options would override.API
Retriable.override(opts)— accepts a hash of config keys to force globally. Only the specified keys are overridden; non-specified keys still respect configure defaults and local options.Retriable.reset_override— clears the override.Retriable.override(contexts: { api: { tries: 1 } })ArgumentError, consistent withRetriable.retriable.Example: Rails test setup
Implementation
The override is stored as a sparse hash delta and merged lazily at each
retriable/with_contextcall usingdeep_merge. This means:Retriable.configureafteroverridestill take effect for non-overridden keysChanges
lib/retriable.rb— addsoverride,reset_override,deep_merge, and supporting merge helpersspec/retriable_spec.rb— 12 new tests covering override precedence, contexts, edge cases, and validationREADME.md— new Override section, updated Testing section with override examplesCHANGELOG.md/lib/retriable/version.rb— version and changelog entriesCloses #108.