mix hammer.install (hammer v7.5.0)

Copy Markdown View Source

Installs Hammer: generates a rate limiter module and adds it to the supervision tree

Generates MyApp.RateLimit (use Hammer, backend: ...) and adds it as a child of the application supervisor. Hammer has no global configuration: limits are defined at each call site with MyApp.RateLimit.hit(key, scale, limit), so after installing, see the Hammer tutorial for how to compose keys and wire the limiter into a plug.

Example

mix hammer.install --backend ets

Options

  • --backend or -b - The backend to use. One of ets (default), atomic or redis. redis also adds the hammer_backend_redis dependency.