AshRateLimiter.BuiltinChanges (ash_rate_limiter v2.0.1)

Copy Markdown

Change helpers to allow direct usage in mutation actions.

Summary

Functions

Add a rate-limit change directly to an action.

Types

rate_limit_options()

@type rate_limit_options() :: [
  limit: pos_integer(),
  per: pos_integer(),
  key: String.t() | AshRateLimiter.keyfun(),
  on: :before_action | :before_transaction
]

Functions

rate_limit(options)

@spec rate_limit(rate_limit_options()) ::
  {AshRateLimiter.Change, rate_limit_options()}

Add a rate-limit change directly to an action.

Options

  • :limit (pos_integer/0) - Required. The maximum number of events allowed within the given scale

  • :per (pos_integer/0) - Required. The time period (in milliseconds) for in which events are counted

  • :key - The key used to identify the event. See the docs for AshRateLimiter.key_for_action/2 for more. The default value is &AshRateLimiter.key_for_action/2.

  • :on - The lifecycle hook to use for rate limiting. :before_action runs inside the transaction; :before_transaction runs outside the transaction, after validations. Valid values are :before_action, :before_transaction The default value is :before_action.