aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md9
-rw-r--r--pom.xml4
-rw-r--r--src/com/github/ivarref/yoltq.clj33
3 files changed, 39 insertions, 7 deletions
diff --git a/README.md b/README.md
index 8ead585..c62328c 100644
--- a/README.md
+++ b/README.md
@@ -333,6 +333,15 @@ easier.
## Change log
+#### 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)`.
+
+Improved:
+`unhealthy?` will return `false` for the first 10 minutes of the application lifetime.
+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.
+
#### 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
the following:
diff --git a/pom.xml b/pom.xml
index c45ccd9..2d992c9 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.56</version>
+ <version>0.2.57</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.56</tag>
+ <tag>v0.2.57</tag>
<url>https://github.com/ivarref/yoltq</url>
</scm>
</project> \ No newline at end of file
diff --git a/src/com/github/ivarref/yoltq.clj b/src/com/github/ivarref/yoltq.clj
index ba27d2c..f4c2bf7 100644
--- a/src/com/github/ivarref/yoltq.clj
+++ b/src/com/github/ivarref/yoltq.clj
@@ -10,7 +10,8 @@
[datomic.api :as d])
(:import (datomic Connection)
(java.time Duration)
- (java.util.concurrent ExecutorService Executors TimeUnit)))
+ (java.util.concurrent ExecutorService Executors TimeUnit)
+ (java.lang.management ManagementFactory)))
(defonce ^:dynamic *config* (atom nil))
@@ -168,12 +169,14 @@
(defn healthy? []
- (some->> @*config*
- :healthy?
- (deref)))
+ (or
+ (< (.toMinutes (Duration/ofMillis (.getUptime (ManagementFactory/getRuntimeMXBean)))) 10)
+ (some->> @*config*
+ :healthy?
+ (deref))))
(defn unhealthy?
- "Returns `true` if there are queues in error, otherwise `false`."
+ "Returns `true` if there are queues in error and application has been up for over 10 minutes, otherwise `false`."
[]
(false? (healthy?)))
@@ -198,6 +201,26 @@
(sort-by (juxt :qname :status))
(vec))))
+(defn get-errors [qname]
+ (let [{:keys [conn]} @*config*
+ db (d/db conn)]
+ (->> (d/q '[:find [?id ...]
+ :in $ ?qname ?status
+ :where
+ [?e :com.github.ivarref.yoltq/queue-name ?qname]
+ [?e :com.github.ivarref.yoltq/status ?status]
+ [?e :com.github.ivarref.yoltq/id ?id]]
+ db
+ qname
+ :error)
+ (mapv (partial u/get-queue-item db)))))
+
+(defn retry-one-error! [qname]
+ (let [{:keys [handlers] :as cfg} @*config*
+ _ (assert (contains? handlers qname) "Queue not found")
+ cfg (assoc-in cfg [:handlers qname :max-retries] Integer/MAX_VALUE)]
+ (poller/poll-once! cfg qname :error)))
+
(comment
(do
(require 'com.github.ivarref.yoltq.log-init)