Functions compiled policies call on the request path.
Summary
Functions
Checks the hard limits of policy, returning the first exceeded.
Describes a limit for humans.
Maps a score to a proof-of-work difficulty in leading zero bits.
The value of parameter name in the instance's :params, or default.
The sliding-window rate of dimension over window, as tracked for the
current policy by track/2.
Whether the HTTP shape signal raised flag.
Counts the request in every rate window policy refers to, and stores the
resulting rates in the context.
A score weight from parameter name: its configured value when it is an
integer, else default.
Functions
@spec check_limits(module(), Limen.Context.t()) :: :ok | {:exceeded, Limen.Decision.Match.t(), pos_integer()}
Checks the hard limits of policy, returning the first exceeded.
Describes a limit for humans.
@spec difficulty_for(integer(), keyword()) :: pos_integer()
Maps a score to a proof-of-work difficulty in leading zero bits.
Scores up to :from get :base bits; every :step points above that add
one bit, up to :max. Each extra bit doubles the expected work.
iex> Limen.Policy.Runtime.difficulty_for(40)
16
iex> Limen.Policy.Runtime.difficulty_for(85)
18
iex> Limen.Policy.Runtime.difficulty_for(1_000)
22
@spec param(Limen.Context.t(), atom(), term()) :: term()
The value of parameter name in the instance's :params, or default.
@spec rate(Limen.Context.t(), atom(), atom()) :: non_neg_integer()
The sliding-window rate of dimension over window, as tracked for the
current policy by track/2.
@spec shape_flag?(Limen.Context.t(), atom()) :: boolean()
Whether the HTTP shape signal raised flag.
@spec track(module(), Limen.Context.t()) :: Limen.Context.t()
Counts the request in every rate window policy refers to, and stores the
resulting rates in the context.
Runs for every request the policy covers, including pass holders, so rates reflect all traffic.
@spec weight(Limen.Context.t(), atom(), integer()) :: integer()
A score weight from parameter name: its configured value when it is an
integer, else default.