Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rack/rack-attack
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: tablecheck/rack-attack
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 5 commits
  • 10 files changed
  • 1 contributor

Commits on Mar 20, 2022

  1. This PR adds several features and changes to error handling:

    - Catch and handle all errors once per request.
    - Remove the `rescuing` blocks from the store proxies; rescuing per-method (read, write, increment) is bad because (a) it may result in undefined behavior, and (b) it will trigger repeated connection timeouts if your cache is down, e.g. N * M * timeout latency where N is the number of Rack::Attack metrics and M is the cache requests per metric.
    - Add `Rack::Attack.ignored_errors` config. This defaults to Dalli::DalliError and Redis::BaseError.
    - Add `Rack::Attack.failure_cooldown` config. This temporarily disables Rack::Attack after an error occurs (including ignored errors), to prevent cache connection latency. The default is 60 seconds.
    - Add `Rack::Attack.error_handler` which takes a Proc for custom error handling. It's probably not needed but there may be esoteric use cases for it. You can also use the shortcut symbols :block, :throttle, and :allow to respond to errors using those.
    - Add `Rack::Attack.calling?` method which uses Thread.current (or RequestStore, if available) to indicate that Rack::Attack code is executing. The reason for this is to add custom error handlers in the Rails Cache, i.e. "raise the error if it occurred while Rack::Attack was executing, so that Rack::Attack and handle it." Refer to readme.
    - Add "Fault Tolerance & Error Handling" section to Readme which includes all of the above.
    johnnyshields committed Mar 20, 2022
    Configuration menu
    Copy the full SHA
    ae9d7fd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d3853e8 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    78c0939 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6af71d3 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    59d5619 View commit details
    Browse the repository at this point in the history
Loading