AshRateLimiter.BuiltinChanges (ash_rate_limiter v0.1.2)

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()
]

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.