sregulator_rate_valve (sbroker v1.1.1)
Implements a valve with a rate limit between a minimum and maximum capacity.
sregulator_rate_value
can be used as the sregulator_valve
in a sregulator
. It will provide a valve that limits the rate of tasks when between a minimum and maximum capacity. Its argument, spec()
, is of the form: #{limit => Limit :: non_neg_integer(), % default: 100
interval => Interval :: pos_integer(), % default: 1000
min => Min :: non_neg_integer(), % default: 0
max => Max :: non_neg_integer() | infinity}. % default: infinity
Limit
is the number of new tasks (defaults to 100
) that can run when the number of concurrent tasks is at or above the minimum capacity, Min
(defaults to 0
), and below the maximum capacity, Max
(defaults to infinity
). The limit is temporarily reduced by 1
for Interval
milliseconds (defaults to 1000
) after a task is done and the capacity is above Min
. Also the limit is restricted to 0
for Interval
milliseconds after the valve is started. This ensures that no more than Limit
tasks can run above the minimum capacity for any time interval of Interval
milliseconds, even if the sregulator
is restarted.
Link to this section Summary
Link to this section Types
Link to this type
spec/0
Specs
spec() :: #{limit => non_neg_integer(), interval => pos_integer(), min => non_neg_integer(), max => non_neg_integer() | infinity}.