Queues

Biff can create concurrent queues and thread pools for you. For example:

(defn echo-consumer [{:keys [biff/job] :as ctx}]
  (prn :echo job)
  (when-some [callback (:biff/callback job)]
    (callback job)))

(def module
  {:queues [{:id :echo
             :consumer #'echo-consumer
             :n-threads 1}]})

(biff/submit-job ctx :echo {:foo "bar"})
=>
(out) :echo {:foo "bar"}
true

@(biff/submit-job-for-result ctx :echo {:foo "bar"})
=>
(out) :echo {:foo "bar", :biff/callback #function[...]}
{:foo "bar", :biff/callback #function[...]}"

This can be useful for limiting the concurrency of certain operations. Note that these queues are in-memory only; they are not persisted to the database. There is also no retry logic for jobs that throw an exception.

See also:

Have a question? Join the #biff channel on Clojurians Slack, or ask on GitHub.

Sign up for Biff: The Newsletter
Announcements, blog posts, et cetera et cetera.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.