Skip to content
forked from dpep/berater_rb

work within limits

License

Notifications You must be signed in to change notification settings

1debit/berater_rb

This branch is 4 commits behind dpep/berater_rb:main.

Folders and files

NameName
Last commit message
Last commit date
Apr 10, 2024
Feb 6, 2024
Oct 13, 2023
Mar 4, 2021
Feb 4, 2021
Oct 13, 2023
Jan 29, 2021
Feb 6, 2024
Oct 11, 2022
Feb 6, 2024
Aug 29, 2017
Aug 17, 2022
Oct 13, 2023

Repository files navigation

Berater

Gem codecov

All systems have limits, beyond which they tend to fail. Berater makes working within limits easy and the inevitable failures more graceful.

require 'berater'
require 'redis'

Berater.configure do |c|
  c.redis = Redis.new
end

Berater(:key, 3) do
  # allow only three simultaneous requests at a time, with a concurrency limiter
end

Berater(:key, 2, interval: 60) do
  # or do work twice per minute with a rate limiter
end

See documentation for details.


Contributing

Yes please :)

  1. Fork it
  2. Create your feature branch (git checkout -b my-feature)
  3. Ensure the tests pass (bundle exec rspec)
  4. Commit your changes (git commit -am 'awesome new feature')
  5. Push your branch (git push origin my-feature)
  6. Create a pull request

Inspired by

https://stripe.com/blog/rate-limiters

https://github.blog/2021-04-05-how-we-scaled-github-api-sharded-replicated-rate-limiter-redis

@ptarjan

https://en.wikipedia.org/wiki/Leaky_bucket

Packages

No packages published

Languages

  • Ruby 100.0%