Skip to content

Commit 2ef4072

Browse files
committed
remove :refer :all
Signed-off-by: Sean Corfield <[email protected]>
1 parent 9776db0 commit 2ef4072

File tree

3 files changed

+73
-60
lines changed

3 files changed

+73
-60
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## CHANGES
2+
3+
v0.1.8 in progress
4+
* Clean up lint issues; export clj-kondo config
5+
* Add a changelog!
6+
7+
v0.1.7 -- 2025-09-02
8+
* Bring all dependencies up to date
9+
* Matrix test against Clojure 1.10, 1.11, and 1.12
10+
* Matrix test against JDK 11, 17, and 21 (also tested on JDK 24 manually)
11+
* Add `deps.edn`, `bb.edn`, `build.clj`
12+
* Add GitHub Actions for test, snapshot, and release
13+
* Remove non-functional CircleCI integration

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ This library implements a disk-backed task queue, allowing for queues that can s
1515
To interact with queues, first create a `queues` object by specifying a directory in the filesystem and an options map:
1616

1717
```clj
18-
> (require '[durable-queue :refer :all])
18+
> (require '[durable-queue :as dq])
1919
nil
20-
> (def q (queues "/tmp" {}))
20+
> (def q (dq/queues "/tmp" {}))
2121
#'q
2222
```
2323

2424
This allows us to `put!` and `take!` tasks from named queues. `take!` is a blocking read, and will only return once a task is available or, if a timeout is defined (in milliseconds), once the timeout elapses:
2525

2626
```clj
27-
> (take! q :foo 10 :timed-out!)
27+
> (dq/take! q :foo 10 :timed-out!)
2828
:timed-out!
29-
> (put! q :foo "a task")
29+
> (dq/put! q :foo "a task")
3030
true
31-
> (take! q :foo)
31+
> (dq/take! q :foo)
3232
< :in-progress | "a task" >
3333
> (deref *1)
3434
"a task"
@@ -39,20 +39,20 @@ Notice that the task has a value describing its progress, and a value describing
3939
Calling `take!` removed the task from the queue, but just because we've taken the task doesn't mean we've completed the action associated with it. In order to make sure the task isn't retried on restart, we must mark it as `complete!`.
4040

4141
```clj
42-
> (put! q :foo "another task")
42+
> (dq/put! q :foo "another task")
4343
true
44-
> (take! q :foo)
44+
> (dq/take! q :foo)
4545
< :in-progress | "another task" >
46-
> (complete! *1)
46+
> (dq/complete! *1)
4747
true
4848
```
4949

50-
If our task fails and we want to re-enqueue it to be tried again, we can instead call `(retry! task)`. Tasks which are marked for retry are added to the end of the current queue.
50+
If our task fails and we want to re-enqueue it to be tried again, we can instead call `(dq/retry! task)`. Tasks which are marked for retry are added to the end of the current queue.
5151

5252
To get a description of the current state of the queue, we can use `stats`, which returns a map of queue names onto various counts:
5353

5454
```clj
55-
> (stats q)
55+
> (dq/stats q)
5656
{:enqueued 2,
5757
:retried 0,
5858
:completed 1,
@@ -90,7 +90,7 @@ A complete list of options is as follows:
9090

9191
Disabling `:fsync-put?` will risk losing tasks if a process dies. Disabling `:fsync-take?` increases the chance of a task being re-run when a process dies. Disabling both will increase throughput of the queue by at least an order of magnitude (in the default configuration, ~1.5k tasks/sec on rotating disks and ~6k tasks/sec on SSD, with fsync completely disabled ~100k tasks/sec independent of hardware).
9292

93-
Writes can be batched using `fsync-threshold` and/or `fsync-interval`, or by explicitly calling `(durable-queue/fsync q)`. Setting the `fsync-threshold` to 10 will allow for ~25k tasks/sec on SSD, and still enforces a small upper boundary on how much data can be lost when the process dies. An exception will be thrown if both per-task and batch sync options are set.
93+
Writes can be batched using `fsync-threshold` and/or `fsync-interval`, or by explicitly calling `(dq/fsync q)`. Setting the `fsync-threshold` to 10 will allow for ~25k tasks/sec on SSD, and still enforces a small upper boundary on how much data can be lost when the process dies. An exception will be thrown if both per-task and batch sync options are set.
9494

9595
### license
9696

test/durable_queue_test.clj

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
(ns durable-queue-test
22
(:require
33
[clojure.java.io :as io]
4-
[clojure.test :refer :all]
5-
[durable-queue :refer :all]
4+
[clojure.test :refer [deftest is]]
5+
[durable-queue :as dq]
66
[criterium.core :as c]))
77

88
(defn clear-tmp-directory []
@@ -13,121 +13,121 @@
1313

1414
(deftest test-basic-put-take
1515
(clear-tmp-directory)
16-
(let [q (queues "/tmp" {:slab-size 1024})
16+
(let [q (dq/queues "/tmp" {:slab-size 1024})
1717
tasks (range 1e4)]
1818
(doseq [t tasks]
19-
(put! q :foo t))
20-
(is (= tasks (map deref (immediate-task-seq q :foo))))
21-
(delete! q)))
19+
(dq/put! q :foo t))
20+
(is (= tasks (map deref (dq/immediate-task-seq q :foo))))
21+
(dq/delete! q)))
2222

2323
(deftest test-partial-slab-writes
2424
(clear-tmp-directory)
2525
(dotimes [i 10]
26-
(put! (queues "/tmp") :foo i))
27-
(is (= (range 10) (map deref (immediate-task-seq (queues "/tmp") :foo)))))
26+
(dq/put! (dq/queues "/tmp") :foo i))
27+
(is (= (range 10) (map deref (dq/immediate-task-seq (dq/queues "/tmp") :foo)))))
2828

2929
(deftest test-retry
3030
(clear-tmp-directory)
31-
(with-open [^java.io.Closeable q (queues "/tmp")]
31+
(with-open [^java.io.Closeable q (dq/queues "/tmp")]
3232

3333
(doseq [t (range 10)]
34-
(put! q :foo t))
34+
(dq/put! q :foo t))
3535

36-
(let [tasks' (immediate-task-seq q :foo)]
36+
(let [tasks' (dq/immediate-task-seq q :foo)]
3737
(is (= (range 10) (map deref tasks')))
3838
(doseq [t (take 5 tasks')]
39-
(complete! t))
39+
(dq/complete! t))
4040
(doseq [t (range 10 15)]
41-
(put! q :foo t))))
41+
(dq/put! q :foo t))))
4242

4343
;; create a new manager, which will mark all in-progress tasks as incomplete
44-
(with-open [^java.io.Closeable q (queues "/tmp")]
45-
(let [tasks' (immediate-task-seq q :foo)]
44+
(with-open [^java.io.Closeable q (dq/queues "/tmp")]
45+
(let [tasks' (dq/immediate-task-seq q :foo)]
4646
(is (= (range 5 15) (map deref tasks')))
4747
(doseq [t (take 5 tasks')]
48-
(complete! t))))
48+
(dq/complete! t))))
4949

50-
(with-open [^java.io.Closeable q (queues "/tmp")]
51-
(let [tasks' (immediate-task-seq q :foo)]
50+
(with-open [^java.io.Closeable q (dq/queues "/tmp")]
51+
(let [tasks' (dq/immediate-task-seq q :foo)]
5252
(is (= (range 10 15) (map deref tasks')))
5353
(doseq [t (range 15 20)]
54-
(put! q :foo t))))
54+
(dq/put! q :foo t))))
5555

56-
(let [q (queues "/tmp" {:complete? even?})]
57-
(is (= (remove even? (range 10 20)) (map deref (immediate-task-seq q :foo))))))
56+
(let [q (dq/queues "/tmp" {:complete? even?})]
57+
(is (= (remove even? (range 10 20)) (map deref (dq/immediate-task-seq q :foo))))))
5858

5959
;;;
6060

6161
(deftest ^:benchmark benchmark-put-take
6262
(clear-tmp-directory)
6363

6464
(println "\n\n-- sync both")
65-
(let [q (queues "/tmp" {:fsync-put? true, :fsync-take? true})]
65+
(let [q (dq/queues "/tmp" {:fsync-put? true, :fsync-take? true})]
6666
(c/quick-bench
6767
(do
68-
(put! q :foo 1)
69-
(complete! (take! q :foo)))))
68+
(dq/put! q :foo 1)
69+
(dq/complete! (dq/take! q :foo)))))
7070

7171
(println "\n\n-- sync take")
72-
(let [q (queues "/tmp" {:fsync-put? false, :fsync-take? true})]
72+
(let [q (dq/queues "/tmp" {:fsync-put? false, :fsync-take? true})]
7373
(c/quick-bench
7474
(do
75-
(put! q :foo 1)
76-
(complete! (take! q :foo)))))
75+
(dq/put! q :foo 1)
76+
(dq/complete! (dq/take! q :foo)))))
7777

7878
(println "\n\n-- sync put")
79-
(let [q (queues "/tmp" {:fsync-put? true, :fsync-take? false})]
79+
(let [q (dq/queues "/tmp" {:fsync-put? true, :fsync-take? false})]
8080
(c/quick-bench
8181
(do
82-
(put! q :foo 1)
83-
(complete! (take! q :foo)))))
82+
(dq/put! q :foo 1)
83+
(dq/complete! (dq/take! q :foo)))))
8484

8585
(println "\n\n-- sync every 10 writes")
86-
(let [q (queues "/tmp" {:fsync-put? false, :fsync-threshold 10})]
86+
(let [q (dq/queues "/tmp" {:fsync-put? false, :fsync-threshold 10})]
8787
(c/quick-bench
8888
(do
89-
(put! q :foo 1)
90-
(complete! (take! q :foo)))))
89+
(dq/put! q :foo 1)
90+
(dq/complete! (dq/take! q :foo)))))
9191

9292
(println "\n\n-- sync every 100 writes")
93-
(let [q (queues "/tmp" {:fsync-put? false, :fsync-threshold 100})]
93+
(let [q (dq/queues "/tmp" {:fsync-put? false, :fsync-threshold 100})]
9494
(c/quick-bench
9595
(do
96-
(put! q :foo 1)
97-
(complete! (take! q :foo)))))
96+
(dq/put! q :foo 1)
97+
(dq/complete! (dq/take! q :foo)))))
9898

9999
(println "\n\n-- sync every 100ms")
100-
(let [q (queues "/tmp" {:fsync-put? false, :fsync-interval 100})]
100+
(let [q (dq/queues "/tmp" {:fsync-put? false, :fsync-interval 100})]
101101
(c/quick-bench
102102
(do
103-
(put! q :foo 1)
104-
(complete! (take! q :foo)))))
103+
(dq/put! q :foo 1)
104+
(dq/complete! (dq/take! q :foo)))))
105105

106106
(println "\n\n-- sync neither")
107-
(let [q (queues "/tmp" {:fsync-put? false, :fsync-take? false})]
107+
(let [q (dq/queues "/tmp" {:fsync-put? false, :fsync-take? false})]
108108
(c/quick-bench
109109
(do
110-
(put! q :foo 1)
111-
(complete! (take! q :foo))))))
110+
(dq/put! q :foo 1)
111+
(dq/complete! (dq/take! q :foo))))))
112112

113113
;;;
114114

115115
(deftest ^:stress stress-queue-size
116116
(clear-tmp-directory)
117117

118-
(with-open [^java.io.Closeable q (queues "/tmp")]
118+
(with-open [^java.io.Closeable q (dq/queues "/tmp")]
119119
(let [ary (byte-array 1e6)]
120120
(dotimes [i 1e6]
121121
(aset ary i (byte (rand-int 127))))
122122
(dotimes [_ 1e5]
123-
(put! q :stress ary))))
123+
(dq/put! q :stress ary))))
124124

125-
(with-open [^java.io.Closeable q (queues "/tmp" {:complete? (constantly false)})]
126-
(let [s (doall (immediate-task-seq q :stress))]
125+
(with-open [^java.io.Closeable q (dq/queues "/tmp" {:complete? (constantly false)})]
126+
(let [s (doall (dq/immediate-task-seq q :stress))]
127127
(doseq [t s]
128-
(retry! t)))
129-
(let [s (immediate-task-seq q :stress)]
128+
(dq/retry! t)))
129+
(let [s (dq/immediate-task-seq q :stress)]
130130
(doseq [t s]
131-
(complete! t))))
131+
(dq/complete! t))))
132132

133133
(clear-tmp-directory))

0 commit comments

Comments
 (0)