Dear Clojurians,

We've released a small queuing library which fills a gap that core.async 
didn't really fill for us.

https://github.com/acrolinx/clj-queue-by

* A central, easy to use, thread-safe, in-memory working queue.
* Easy to inspect to allow monitoring.
* Stateful, not persistent, uses clojure.lang.PersistentQueue internally.
* With a scheduling algorithm that schedules fairly with respect to a key.

Think of several users adding items to the queue where each item has a :user 
field. Using the :user key-fn, *clj-queue-by *allows fair processing of 
events so that each user gets their own queue under the hood. When one user 
floods the system, the others don't have to wait for the bulk of items to 
be processed completely but move forward (almost) to the head of the queue.


Interface is somewhat unusual: The queue is a callable thing (implements 
IFn). With zero args it reads from the queue with one arg, it queues the 
argument.

(require '[com.acrolinx.clj-queue-by :as q]))
;; Create queue
(def queue (q/queue-by :name))

;; Queue an item
(queue {:data "whatever" :name "Alice"})

;; Inspect
(count queue) ;=> 1
@queue ;=> [#<<() {"Alice" #<<({:data "whatever", :name "Alice"})}]

;; Pop an item from the queue
(queue) ;=> {:data "whatever" :name "Alice"}


Also, the name queue-by was still available. :-)


Hope this makes sense and maybe is useful for others, too.


Kind regards,
stefan

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to