Implements rate limiters, which throttle fns that are called too often.
Implements rate limiters, which throttle fns that are called too often. See https://resilience4j.readme.io/docs/ratelimiter
Set this to override the R4j defaults with your own
Set this to override the R4j defaults with your own
(add-listeners rl {:keys [on-success on-failure]})
Add event handlers for RateLimiter lifecycle events.
Config map options:
:on-success
- a handler that runs after a successful call - receives a RateLimiterOnSuccessEvent:on-failure
- a handler that runs after an failure - receives a RateLimiterOnFailureEventAdd event handlers for RateLimiter lifecycle events. Config map options: - `:on-success` - a handler that runs after a successful call - receives a RateLimiterOnSuccessEvent - `:on-failure` - a handler that runs after an failure - receives a RateLimiterOnFailureEvent
(metrics rl)
Returns metrics for the given rate limiter. Mostly useful for debugging.
Available permission count is an estimate. Can be negative if some permissions were reserved.
The number of waiting threads is also only an estimate.
Returns metrics for the given rate limiter. Mostly useful for debugging. Available permission count is an estimate. Can be negative if some permissions were reserved. The number of waiting threads is also only an estimate.
(rate-limiter rate-limiter-name config)
Creates a RateLimiter
Creates a RateLimiter
(rate-limiter-config config)
Creates a Resilience4j RateLimiterConfig.
Config map options
:limit-for-period
- the number of calls allowed per time window - defaults to 50:limit-refresh-period
- the Duration of the time window - defaults to 500 nanoseconds - accepts number of milliseconds or java.time.Duration:timeout-duration
- how long to wait to be allowed to proceed before timing out - defaults to 5000 ms - accepts number of milliseconds or java.time.DurationCreates a Resilience4j RateLimiterConfig. Config map options - `:limit-for-period` - the number of calls allowed per time window - defaults to 50 - `:limit-refresh-period` - the Duration of the time window - defaults to 500 nanoseconds - accepts number of milliseconds or java.time.Duration - `:timeout-duration` - how long to wait to be allowed to proceed before timing out - defaults to 5000 ms - accepts number of milliseconds or java.time.Duration
(retrieve f)
Retrieves a rate-limiter from a wrapped fn
Retrieves a rate-limiter from a wrapped fn
(wrap f rl)
Wraps a fn in a RateLimiter. Throws RequestNotPermitted if permission to run was not acquired.
Attaches the rate limiter as metadata on the wrapped fn at :truegrit/rate-limiter
Wraps a fn in a RateLimiter. Throws RequestNotPermitted if permission to run was not acquired. Attaches the rate limiter as metadata on the wrapped fn at :truegrit/rate-limiter
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close