-
Notifications
You must be signed in to change notification settings - Fork 2
Middleware
Berater's middleware layer makes modifying limiter behavior easy, and ships with useful ones to get you started. It works much like Rack/Rails middleware and is powered by meddleware.
If Redis briefly times out or crashes altogether, it shouldn't take limiters and your whole app with it. This middleware improves resiliency by ensuring limiters fail open, so your app keeps working as expected even if Redis does not.
Berater.middleware.use Berater::Middleware::FailOpen
All work is important, but some may be more important. This is especially true when systems approach their limits and we're forced to decide which work gets done and which does not. Specifying priority levels and pre-emptively shedding lower priority work helps ensure that the most important work gets done. The naive approach offered by this middleware is simple, yet effective. (a more optimal implementation is under development)
Berater.middleware.use Berater::Middleware::LoadShedder
limiter.limit(priority: 1) { ... } # high priority
limiter.limit(priority: 5) { ... } # low priority
Capture key metrics like limiter usage and utilization. Currently supports Datadog with rich tagging.
statsd = Datadog::Statsd.new
Berater.middleware.use Berater::Middleware::Statsd, statsd