Liking cljdoc? Tell your friends :D

resilience.ratelimiter


*creation-time*clj

Contextual value represents event create time

Contextual value represents event create time
sourceraw docstring

*rate-limiter-name*clj

Contextual value represents rate limiter name

Contextual value represents rate limiter name
sourceraw docstring

acquire-permissionclj

(acquire-permission limiter)
(acquire-permission limiter permits)

Acquires one or the given number of permissions from this rate limiter, blocking until all the required permissions are available, or the thread is interrupted. Maximum wait time is set by :timeout-millis in rate-limiter-config.

If the current thread is interrupted while waiting for a permit then it won't throw InterruptedException, but its interrupt status will be set.

Returns true if a permit was acquired and false if waiting :timeout-millis elapsed before a permit was acquired

Acquires one or the given number of permissions from this rate limiter, blocking until all the
required permissions are available, or the thread is interrupted. Maximum wait time is set
by `:timeout-millis` in `rate-limiter-config`.

If the current thread is interrupted while waiting for a permit then it won't throw
`InterruptedException`, but its interrupt status will be set.

Returns true if a permit was acquired and false if waiting `:timeout-millis`
elapsed before a permit was acquired
sourceraw docstring

change-limit-for-period!clj

(change-limit-for-period! limiter limit)

Dynamic rate limiter configuration change. This method allows to change count of permissions available during refresh period. NOTE! New limit won't affect current period permissions and will apply only from next one.

Dynamic rate limiter configuration change.
This method allows to change count of permissions available during refresh period.
NOTE! New limit won't affect current period permissions and will apply only from next one.
sourceraw docstring

change-timeout-millis!clj

(change-timeout-millis! limiter timeout-millis)

Dynamic rate limiter configuration change. This method allows to change timeout-millis of current limiter. NOTE! New timeout-millis won't affect threads that are currently waiting for permission.

Dynamic rate limiter configuration change.
This method allows to change timeout-millis of current limiter.
NOTE! New timeout-millis won't affect threads that are currently waiting for permission.
sourceraw docstring

configclj

(config limiter)

Get the RateLimiterConfig of this RateLimiter

Get the RateLimiterConfig of this RateLimiter
sourceraw docstring

defratelimitercljmacro

(defratelimiter name)
(defratelimiter name config)

Define a rate limiter under name with a default or custom rate limiter configuration.

Please refer to rate-limiter-config for allowed key value pairs within the rate limiter configuration.

If you want to register this rate limiter to a RateLimiterRegistry, you need to put :registry key with a RateLimiterRegistry in the config argument. If you do not provide any other configurations, the newly created rate limiter will inherit rate limiter configurations from this provided RateLimiterRegistry Example: (defratelimiter my-rate-limiter {:registry my-registry})

If you want to register this rate limiter to a RateLimiterRegistry and you want to use new rate limiter configurations to overwrite the configurations inherited from the registered RateLimiterRegistry, you need not only provide the :registry key with the RateLimiterRegistry in config argument but also provide other rate limiter configurations you'd like to overwrite. Example: (defratelimiter my-rate-limiter {:registry my-registry :timeout-millis 50})

If you only want to create a rate limiter and not register it to any RateLimiterRegistry, you just need to provide rate limiter configuration in config argument without :registry keyword.

Define a rate limiter under `name` with a default or custom rate limiter configuration.

Please refer to `rate-limiter-config` for allowed key value pairs
within the rate limiter configuration.

If you want to register this rate limiter to a RateLimiterRegistry,
you need to put :registry key with a RateLimiterRegistry in the `config`
argument. If you do not provide any other configurations, the newly created
rate limiter will inherit rate limiter configurations from this
provided RateLimiterRegistry
Example:
(defratelimiter my-rate-limiter {:registry my-registry})

If you want to register this rate limiter to a RateLimiterRegistry
and you want to use new rate limiter configurations to overwrite the configurations
inherited from the registered RateLimiterRegistry,
you need not only provide the :registry key with the RateLimiterRegistry in `config`
argument but also provide other rate limiter configurations you'd like to overwrite.
Example:
(defratelimiter my-rate-limiter {:registry my-registry
                                 :timeout-millis 50})

If you only want to create a rate limiter and not register it to any
RateLimiterRegistry, you just need to provide rate limiter configuration in `config`
argument without :registry keyword.
sourceraw docstring

defregistrycljmacro

(defregistry name)
(defregistry name config)

Define a RateLimiterRegistry under name with a default or custom rate limiter configuration.

Please refer to rate-limiter-config for allowed key value pairs within the rate limiter configuration map.

Define a RateLimiterRegistry under `name` with a default or custom
rate limiter configuration.

Please refer to `rate-limiter-config` for allowed key value pairs
within the rate limiter configuration map.
sourceraw docstring

get-all-rate-limitersclj

(get-all-rate-limiters registry)

Get all rate limiters registered to this rate limiter registry instance

Get all rate limiters registered to this rate limiter registry instance
sourceraw docstring

metricsclj

(metrics limiter)

Get the Metrics of this RateLimiter.

Get the Metrics of this RateLimiter.
sourceraw docstring

nameclj

(name limiter)

Get the name of this RateLimiter

Get the name of this RateLimiter
sourceraw docstring

rate-limiterclj

(rate-limiter name)
(rate-limiter name config)

Create a rate limiter with a name and a default or custom rate limiter configuration.

The name argument is only used to register this newly created rate limiter to a RateLimiterRegistry. If you don't want to bind this rate limiter with a RateLimiterRegistry, the name argument is ignored.

Please refer to rate-limiter-config for allowed key value pairs within the rate limiter configurations map.

If you want to register this rate limiter to a RateLimiterRegistry, you need to put :registry key with a RateLimiterRegistry in the config argument. If you do not provide any other configurations, the newly created rate limiter will inherit rate limiter configurations from this provided RateLimiterRegistry Example: (rate-limiter my-rate-limiter {:registry my-registry})

If you want to register this rate limiter to a RateLimiterRegistry and you want to use new rate limiter configurations to overwrite the configurations inherited from the registered RateLimiterRegistry, you need not only provide the :registry key with the RateLimiterRegistry in config argument but also provide other rate limiter configurations you'd like to overwrite. Example: (rate-limiter my-rate-limiter {:registry my-registry :timeout-millis 50})

If you only want to create a rate limiter and not register it to any RateLimiterRegistry, you just need to provide rate limiter configurations in config argument. The name argument is ignored.

Create a rate limiter with a `name` and a default or custom rate limiter configuration.

The `name` argument is only used to register this newly created rate limiter
to a RateLimiterRegistry. If you don't want to bind this rate limiter with
a RateLimiterRegistry, the `name` argument is ignored.

Please refer to `rate-limiter-config` for allowed key value pairs
within the rate limiter configurations map.

If you want to register this rate limiter to a RateLimiterRegistry,
you need to put :registry key with a RateLimiterRegistry in the `config`
argument. If you do not provide any other configurations, the newly created
rate limiter will inherit rate limiter configurations from this
provided RateLimiterRegistry
Example:
(rate-limiter my-rate-limiter {:registry my-registry})

If you want to register this rate limiter to a RateLimiterRegistry
and you want to use new rate limiter configurations to overwrite the configurations
inherited from the registered RateLimiterRegistry,
you need not only provide the :registry key with the RateLimiterRegistry in `config`
argument but also provide other rate limiter configurations you'd like to overwrite.
Example:
(rate-limiter my-rate-limiter {:registry my-registry
                               :timeout-millis 50})

If you only want to create a rate limiter and not register it to any
RateLimiterRegistry, you just need to provide rate limiter configurations in `config`
argument. The `name` argument is ignored.
sourceraw docstring

rate-limiter-configclj

(rate-limiter-config opts)

Create a RateLimiterConfig.

Allowed options are:

  • :writable-stack-trace-enabled Enables writable stack traces. When set to false, Exception#getStackTrace() returns a zero length array. This may be used to reduce log spam when the circuit breaker is open as the cause of the exceptions is already known (the circuit breaker is short-circuiting calls).

  • :timeout-millis Configures the default wait for permission duration. Default value is 5000 milliseconds.

  • :limit-for-period Configures the permissions limit for refresh period. Count of permissions available during one rate limiter period specified by :limit-refresh-period-nanos value. Default value is 50.

  • :limit-refresh-period-nanos Configures the period of limit refresh. After each period rate limiter sets its permissions count to :limit-for-period value. Default value is 500 nanoseconds.

Create a RateLimiterConfig.

Allowed options are:
* :writable-stack-trace-enabled
  Enables writable stack traces. When set to false, Exception#getStackTrace()
  returns a zero length array. This may be used to reduce log spam when the circuit breaker
  is open as the cause of the exceptions is already known (the circuit breaker is
  short-circuiting calls).

* :timeout-millis
  Configures the default wait for permission duration.
  Default value is 5000 milliseconds.

* :limit-for-period
  Configures the permissions limit for refresh period.
  Count of permissions available during one rate limiter period specified by
  :limit-refresh-period-nanos value.
  Default value is 50.

* :limit-refresh-period-nanos
  Configures the period of limit refresh.
  After each period rate limiter sets its permissions count to :limit-for-period value.
  Default value is 500 nanoseconds.
 
sourceraw docstring

registry-with-configclj

(registry-with-config config)

Create a RateLimiterRegistry with a rate limiter configurations map.

Please refer to rate-limiter-config for allowed key value pairs within the rate limiter configuration map.

Create a RateLimiterRegistry with a rate limiter configurations map.

Please refer to `rate-limiter-config` for allowed key value pairs
within the rate limiter configuration map.
sourceraw docstring

reserve-permissionclj

(reserve-permission limiter)
(reserve-permission limiter permits)

Reserves one or the given number permits from this rate limiter and returns nanoseconds you should wait for it. If returned long is negative, it means that you failed to reserve permission, possibly your :timeout-millis in rate-limiter-config is less then time to wait for permission.

Reserves one or the given number permits from this rate limiter and returns nanoseconds you should
wait for it. If returned long is negative, it means that you failed to reserve permission,
possibly your `:timeout-millis` in `rate-limiter-config` is less then time to wait for
permission.
sourceraw docstring

set-on-all-event-consumer!clj

(set-on-all-event-consumer! rate-limiter consumer-fn-map)
source

set-on-failed-acquire-event-consumer!clj

(set-on-failed-acquire-event-consumer! rate-limiter consumer-fn)
source

set-on-successful-acquire-event-consumer!clj

(set-on-successful-acquire-event-consumer! rate-limiter consumer-fn)
source

wait-for-permissionclj

(wait-for-permission limiter)
(wait-for-permission limiter permits)

Will wait for one or required number of permits within default timeout duration.

Will wait for one or required number of permits within default timeout duration.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close