(check {:keys [attempts exception-field-key] :as throttler} keyy)Throttle an API call based on values of keyy. Each call to this function will record keyy to throttler's
internal list; if the number of entires containing keyy exceed throttler's thresholds, throw an exception.
(defendpoint POST [:as {{:keys [email]} :body}] (throttle/check email-throttler email) ...)
Throttle an API call based on values of `keyy`. Each call to this function will record `keyy` to `throttler`'s
internal list; if the number of entires containing `keyy` exceed `throttler`'s thresholds, throw an exception.
(defendpoint POST [:as {{:keys [email]} :body}]
(throttle/check email-throttler email)
...)(make-throttler exception-field-key & {:as kwargs})Create a new Throttler.
(require '[metabase.api.common.throttle :as throttle]) (def email-throttler (throttle/make-throttler :email, :attempts-threshold 10))
Create a new `Throttler`. (require '[metabase.api.common.throttle :as throttle]) (def email-throttler (throttle/make-throttler :email, :attempts-threshold 10))
(with-throttling [throttler key & more] & body)Do body if failed attempts for keyy on throttler has not been exceeded.
If body throws an exception, a failed attempt is counted and the exception is re-thrown. If the failed attempts
threshold is exceeded, an exception is thrown and body is not executed. Attempts made while the threshold is
exceeded are counted as additional failed attempts.
Do `body` if failed attempts for `keyy` on `throttler` has not been exceeded. If `body` throws an exception, a failed attempt is counted and the exception is re-thrown. If the failed attempts threshold is exceeded, an exception is thrown and `body` is not executed. Attempts made while the threshold is exceeded are counted as additional failed attempts.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |