ExternalService.RateLimited exception (ExternalService v2.6.0)

Copy Markdown View Source

Raised or returned when a call could not be made within the service's configured rate limit :wait budget.

This is an Errata infrastructure error. The same value is returned in an {:error, error} tuple by ExternalService.call/3 and raised by ExternalService.call!/3.

Its :context contains:

  • :service — the service the call was made against.
  • :retry_after — milliseconds until the call would have been admitted, as reported by the rate limiter backend.

Only services that bound the wait — rate_limit: [wait: false] or a millisecond budget — can produce this error; wait: :infinity, and leaving :wait unset, wait as long as it takes instead. Because the wrapped function never ran, this does not melt the circuit breaker and is not retried — retrying immediately would only be throttled again.

Summary

Functions

Returns the HTTP status code associated with this error (503 by default).

Types

Functions

http_status(error)

@spec http_status(Errata.error()) :: non_neg_integer()

Returns the HTTP status code associated with this error (503 by default).

The default is derived from the error's kind, or set via the :http_status option. Override this function to compute a status from the error's :reason or :context. See also Errata.http_status/1.