Implements thread-pool-based bulkheads. Due to tricky interactions with Clojure thread expectations, consider the default semaphore-based bulkhead instead, and take care when using.
Implements thread-pool-based bulkheads. Due to tricky interactions with Clojure thread expectations, consider the default semaphore-based bulkhead instead, and take care when using. See https://resilience4j.readme.io/docs/bulkhead
Set this to override the R4j defaults with your own
Set this to override the R4j defaults with your own
(add-listeners tp
{:keys [on-event on-call-rejected on-call-permitted
on-call-finished]})
Add event handlers for ThreadPoolBulkhead lifecycle events.
Config map options
:on-event
- a handler that runs for all events:on-call-rejected
- a handler that runs when a call was rejected - receives a BulkheadOnCallRejectedEvent:on-call-permitted
- a handler that runs when a call was permitted - receives a BulkheadOnCallPermittedEvent:on-call-finished
- a handler that runs when a call finishes - receives a BulkheadOnCallFinishedEventAdd event handlers for ThreadPoolBulkhead lifecycle events. Config map options - `:on-event` - a handler that runs for all events - `:on-call-rejected` - a handler that runs when a call was rejected - receives a BulkheadOnCallRejectedEvent - `:on-call-permitted` - a handler that runs when a call was permitted - receives a BulkheadOnCallPermittedEvent - `:on-call-finished` - a handler that runs when a call finishes - receives a BulkheadOnCallFinishedEvent
(bulkhead bulkhead-name config)
Creates a ThreadPoolBulkhead with the given name and config.
WARNING: This does not understand Clojure thread frames, and will not convey dynamic vars to the new threads.
In short, binding
and related fns/macros will not work by default. Either use bound-fn
, or pass in/close
over what you need.
NB: No need to await termination when done, it adds a shutdown hook to the runtime.
Creates a ThreadPoolBulkhead with the given name and config. WARNING: This does not understand Clojure thread frames, and will not convey dynamic vars to the new threads. In short, `binding` and related fns/macros will not work by default. Either use `bound-fn`, or pass in/close over what you need. NB: No need to await termination when done, it adds a shutdown hook to the runtime.
(metrics tp)
Returns metrics for the given thread-pool bulkhead.
Returns metrics for the given thread-pool bulkhead.
(retrieve f)
Retrieves a tp-bulkhead from a wrapped fn
Retrieves a tp-bulkhead from a wrapped fn
(tp-bulkhead-config config)
Creates a Resilience4j ThreadPoolBulkheadConfig.
Config map options:
:max-thread-pool-size
- max allowed number of threads - defaults to # of processors:core-thread-pool-size
- default number of threads - defaults to (# of processors - 1):queue-capacity
- incoming task queue capacity - defaults to 100:keep-alive-duration
- when the # of threads exceeds the core size and they've been idle
for this many milliseconds, they will be stopped - defaults to 20 ms - accepts number of ms or java.time.DurationCreates a Resilience4j ThreadPoolBulkheadConfig. Config map options: - `:max-thread-pool-size` - max allowed number of threads - defaults to # of processors - `:core-thread-pool-size` - default number of threads - defaults to (# of processors - 1) - `:queue-capacity` - incoming task queue capacity - defaults to 100 - `:keep-alive-duration` - when the # of threads exceeds the core size and they've been idle for this many milliseconds, they will be stopped - defaults to 20 ms - accepts number of ms or java.time.Duration See https://resilience4j.readme.io/docs/bulkhead
(wrap f tp)
Wraps a function in a ThreadPoolBulkhead. Throws BulkheadFullException if full.
Result is wrapped in a CompletableFuture, which is compatible with deref
.
Attaches the thread-pool bulkhead as metadata on the wrapped fn at :truegrit/tp-bulkhead
Wraps a function in a ThreadPoolBulkhead. Throws BulkheadFullException if full. Result is wrapped in a CompletableFuture, which is compatible with `deref`. Attaches the thread-pool bulkhead as metadata on the wrapped fn at :truegrit/tp-bulkhead
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close