In general, the goal of the bulkhead pattern is to avoid faults in one part of a system to take the entire system down. The bulkhead implementation in promesa limits the number of concurrent calls.
This SO answer explains the concept very well.
So lets stat with an example:
(require '[promesa.exec.bulkhead :as pxb]
'[promesa.exec :as px])
;; All parameters are optional and have default value
(def instance (pxb/create :concurrency 1
:queue-size 16
:executor px/*default-executor*))
@(px/submit! instance (fn []
(Thread/sleep 1000)
1))
;; => 1
At first glance, this seems like an executor instance because it resembles the same API (aka `px/submit! call).
When you submits a task to it, it does the following:
This allows control the concurrency and the queue size on access to some resource.
NOTES:
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close