aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvar Refsdal <refsdal.ivar@gmail.com>2022-06-30 09:52:49 +0200
committerIvar Refsdal <refsdal.ivar@gmail.com>2022-06-30 09:52:49 +0200
commit4fd3c882e5dbe905711d4aaf8f0e4fe52369cef7 (patch)
treee7599238cf775831b24f3720445b3950ba89120d
parentRelease 0.2.57 (diff)
downloadfiinha-4fd3c882e5dbe905711d4aaf8f0e4fe52369cef7.tar.gz
fiinha-4fd3c882e5dbe905711d4aaf8f0e4fe52369cef7.tar.xz
Release 0.2.58
Document limitations, alternatives. Improve pr-str usage
-rw-r--r--README.md48
-rw-r--r--pom.xml4
-rw-r--r--src/com/github/ivarref/yoltq/impl.clj12
3 files changed, 58 insertions, 6 deletions
diff --git a/README.md b/README.md
index c62328c..ade8650 100644
--- a/README.md
+++ b/README.md
@@ -211,7 +211,7 @@ is shut down abruptly during processing of queue jobs.
### Giving up
A queue job will remain in status `:error` once `:max-retries` (default: 100) have been reached.
-Ideally this will not happen.
+Ideally this will not happen. ¯\\\_(ツ)\_/¯
### All configuration options
@@ -285,6 +285,22 @@ Other than this there is no attempt at ordering the execution of queue jobs.
In fact the opposite is done in the poller to guard against the case that a single failing queue job
could effectively take down the entire retry polling job.
+## Retrying jobs in the REPL
+
+```clojure
+(require '[com.github.ivarref.yoltq :as yq])
+
+; List jobs that are in state error:
+(yq/get-errors :q)
+
+; This will retry a single job that is in error, regardless
+; of how many times it has been retried earlier.
+; If the job fails, you will get the full stacktrace on the REPL.
+(yq/retry-one-error! :q)
+; Returns a map containing the new state of the job.
+; Returns nil if there are no (more) jobs in state error for this queue.
+```
+
# Testing
For testing you will probably want determinism over an extra threadpool
@@ -331,8 +347,35 @@ These dynamic bindings will be in place when yoltq logs errors, warnings
etc. about failing consumer functions, possibly making troubleshooting
easier.
+## Limitations
+
+Datomic does not have anything like `for update skip locked`.
+Thus consuming a queue should be limited to a single JVM process.
+This library will take queue jobs by compare-and-swapping a lock+state,
+process the item and then compare-and-swapping the lock+new-state.
+It does so eagerly, thus if you have multiple JVM consumers you will
+most likely get many locking conflicts. It should work, but it's far
+from optimal.
+
+## Alternatives
+
+I did not find any alternatives for Datomic.
+
+If I were using PostgreSQL or any other database that supports
+`for update skip locked`, I'd use a queue that uses this.
+For Clojure there is [proletarian](https://github.com/msolli/proletarian).
+
+For Redis there is [carmine](https://github.com/ptaoussanis/carmine).
+
+Note: I have not tried these libraries myself.
+
## Change log
+#### 2022-06-30 v0.2.58 [diff](https://github.com/ivarref/yoltq/compare/v0.2.57...v0.2.58)
+Slightly more safe EDN printing and parsing.
+Recommended reading:
+[Pitfalls and bumps in Clojure's Extensible Data Notation (EDN)](https://nitor.com/en/articles/pitfalls-and-bumps-clojures-extensible-data-notation-edn)
+
#### 2022-06-29 v0.2.57 [diff](https://github.com/ivarref/yoltq/compare/v0.2.56...v0.2.57)
Added `(get-errors qname)` and `(retry-one-error! qname)`.
@@ -341,6 +384,7 @@ Improved:
This was done in order to push new code while a queue was in error in an earlier
version of the code. In this way rolling upgrades are possible regardless if there
are queue errors.
+Can you tell that this issue hit me? ¯\\\_(ツ)\_/¯
#### 2022-06-22 v0.2.56 [diff](https://github.com/ivarref/yoltq/compare/v0.2.55...v0.2.56)
Added support for `:yoltq/queue-id` metadata on functions. I.e. it's possible to write
@@ -420,7 +464,7 @@ First publicly announced release.
## License
-Copyright © 2021 Ivar Refsdal
+Copyright © 2021-2022 Ivar Refsdal
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
diff --git a/pom.xml b/pom.xml
index 2d992c9..cb293b7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
<packaging>jar</packaging>
<groupId>com.github.ivarref</groupId>
<artifactId>yoltq</artifactId>
- <version>0.2.57</version>
+ <version>0.2.58</version>
<name>yoltq</name>
<dependencies>
<dependency>
@@ -30,7 +30,7 @@
<scm>
<connection>scm:git:git://github.com/ivarref/yoltq.git</connection>
<developerConnection>scm:git:ssh://git@github.com/ivarref/yoltq.git</developerConnection>
- <tag>v0.2.57</tag>
+ <tag>v0.2.58</tag>
<url>https://github.com/ivarref/yoltq</url>
</scm>
</project> \ No newline at end of file
diff --git a/src/com/github/ivarref/yoltq/impl.clj b/src/com/github/ivarref/yoltq/impl.clj
index 6b14ffc..c37b0e6 100644
--- a/src/com/github/ivarref/yoltq/impl.clj
+++ b/src/com/github/ivarref/yoltq/impl.clj
@@ -23,11 +23,19 @@
#:db{:ident :com.github.ivarref.yoltq/error-time, :cardinality :db.cardinality/one, :valueType :db.type/long}
#:db{:ident :com.github.ivarref.yoltq/version, :cardinality :db.cardinality/one, :valueType :db.type/string, :index true}])
+(defn pr-str-inner [x]
+ (binding [*print-dup* false
+ *print-meta* false
+ *print-readably* true
+ *print-length* nil
+ *print-level* nil
+ *print-namespace-maps* false]
+ (pr-str x)))
(defn pr-str-safe [what x]
(try
- (if (= x (edn/read-string (pr-str x)))
- (pr-str x)
+ (if (= x (edn/read-string (pr-str-inner x)))
+ (pr-str-inner x)
(throw (ex-info (str "Could not read-string " what) {:input x})))
(catch Exception e
(log/error "could not read-string" what ":" (ex-message e))