PleaseStop v1.0.1 PleaseStop View Source
Usage
To use PleaseStop
in Phoenix you can use it just like any other plug.
scope "/avatars" do
plug PleaseStop, limit: 5000, ttl: :timer.minutes(1), namespace: :avatars
scope "/something" do
plug PleaseStop, limit: 5, ttl: :timer.minutes(10), namespace: fn (conn) -> conn.assigns.something end
end
end
Options
The options provided to PleaseStop
are detailed below
limit
: The maximum number of requests you’ll accept within the providedttl
.ttl
: The amount of time before the request count is set back to0
. If thelimit
is reached within thisttl
, a429
will be returned and theconn
will be halted.namespace
: The namespace where your rate limiting information is kept. This namespace can be a static value or a function that receives the current connection
Configuration Options
By default PleaseStop uses a poolboy size of 10 with a overflow size of 10. These values can be configured by changing the following config options
config :please_stop,
pool_size: 50,
pool_overflow_size: 100