View Source DebounceAndThrottle.Throttle (Debounce and Throttle v0.9.0)
This module implements the Throttle API.
Link to this section Summary
Functions
Calls a func, but only once during period per key
Calls a fun, but only once during period per key
Sends a message to a given pid, but only once during period per key
Returns the state - the current list of throttled functions. Useful for debugging.
Link to this section Types
Specs
t() :: %DebounceAndThrottle.Throttle{
extra_data: map(),
status: atom(),
throttled_count: non_neg_integer(),
throttled_until: integer(),
throttled_until_utc: DateTime.t()
}
Link to this section Functions
Specs
Calls a func, but only once during period per key
Returns {:ok, %Throttle{}}.
Specs
call((... -> any()), String.t(), non_neg_integer()) :: {:ok, t()}
Calls a fun, but only once during period per key
Returns {:ok, %Throttle{}}.
Specs
Sends a message to a given pid, but only once during period per key
Returns {:ok, %Throttle{}}.
Specs
state() :: map()
Returns the state - the current list of throttled functions. Useful for debugging.
Returns something like: %{ apply: %{}, call: %{
"say_hey" => %DebounceAndThrottle.Throttle{
extra_data: %{fun: #Function<45.65746770/0 in :erl_eval.expr/5>},
status: :executed,
throttled_count: 0,
throttled_until: -576460730743,
throttled_until_utc: ~U[2022-03-12 22:47:39.829107Z]
}
...}, send: %{} }