A small Clojure wrapper around the resilience4j Bulkhead module. Requires Clojure 1.9 or later.
The following code defines a function make-remote-call
that will limit the
number of concurrent calls to an external service using a bulkhead named
:my-bulkhead
in the global registry. If the bulkhead does not already exist in
the global registry, one is created.
If a call would cause the bulkhead to exceed the maximum number of allowable concurrent calls, that call will instead wait for permission to execute. If the call does not receive permission to execute before a timeout period expires, an exception will be thrown.
(ns myproject.some-client
(:require [clj-http.client :as http]
[resilience4clj.bulkhead :refer [with-bulkhead]])
(defn make-remote-call []
(with-bulkhead :my-bulkhead
(http/get "https://www.example.com")))
Refer to the configuration guide for more information on how to configure the global registry as well as individual bulkheads.
Refer to the usage guide for more information on how to use bulkheads.
Copyright © 2020 Thomas C. Taylor and contributors.
Distributed under the Eclipse Public License version 2.0.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close