aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md30
-rw-r--r--deps.edn8
-rw-r--r--pom.xml4
-rwxr-xr-xrelease.sh4
-rw-r--r--src/com/github/ivarref/yoltq.clj32
-rw-r--r--src/com/github/ivarref/yoltq/error_poller.clj19
-rw-r--r--test/com/github/ivarref/yoltq/error_poller_test.clj2
7 files changed, 80 insertions, 19 deletions
diff --git a/README.md b/README.md
index 7e49431..f62d46c 100644
--- a/README.md
+++ b/README.md
@@ -331,6 +331,34 @@ These dynamic bindings will be in place when yoltq logs errors, warnings
etc. about failing consumer functions, possibly making troubleshooting
easier.
+## Change log
+
+### 2022-03-27 v0.2.41
+```
+ Added function `healthy?` that returns:
+ true if no errors
+ false if one or more errors
+ nil if error-poller is yet to be executed.
+
+ Added default functions for `:on-system-error` and `:on-system-recovery`
+ that simply logs that the system is in error (ERROR level) or has
+ recovered (INFO level).
+
+ Added function `queue-stats` that returns a nicely "formatted"
+ vector of queue stats, for example:
+ (queue-stats)
+ =>
+ [{:qname :add-message-thread, :status :done, :count 10274}
+ {:qname :add-message-thread, :status :init, :count 30}
+ {:qname :add-message-thread, :status :processing, :count 1}
+ {:qname :send-message, :status :done, :count 21106}
+ {:qname :send-message, :status :init, :count 56}]
+```
+
+### 2021-09-27 v0.2.39: ?
+### 2021-09-27 v0.2.37: ?
+
+### 2021-09-24 v0.2.33: First publicly announced release.
## License
@@ -345,4 +373,4 @@ Licenses when the conditions for such availability set forth in the Eclipse
Public License, v. 2.0 are satisfied: GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or (at your
option) any later version, with the GNU Classpath Exception which is available
-at https://www.gnu.org/software/classpath/license.html. \ No newline at end of file
+at https://www.gnu.org/software/classpath/license.html.
diff --git a/deps.edn b/deps.edn
index a457628..d0f0a26 100644
--- a/deps.edn
+++ b/deps.edn
@@ -22,8 +22,10 @@
:release {:extra-deps {ivarref/pom-patch {:mvn/version "0.1.16"}}}
- :deploy {:extra-deps {slipset/deps-deploy {:mvn/version "0.1.3"}}
- :main-opts ["-m" "deps-deploy.deps-deploy" "deploy"
- "target/out.jar" "true"]}}
+ :deploy {:extra-deps {slipset/deps-deploy {:mvn/version "0.2.0"}}
+ :exec-fn deps-deploy.deps-deploy/deploy
+ :exec-args {:installer :remote
+ :sign-releases? false
+ :artifact "target/out.jar"}}}
:mvn/repos {"my.datomic.com" {:url "https://my.datomic.com/repo"}}}
diff --git a/pom.xml b/pom.xml
index 9784836..e486fb1 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.39</version>
+ <version>0.2.40</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.39</tag>
+ <tag>v0.2.40</tag>
<url>https://github.com/ivarref/yoltq</url>
</scm>
</project> \ No newline at end of file
diff --git a/release.sh b/release.sh
index 70f67b5..dec59a2 100755
--- a/release.sh
+++ b/release.sh
@@ -13,8 +13,6 @@ git commit -m "Release $VERSION"
git tag -a v$VERSION -m "Release v$VERSION"
git push --follow-tags
-clojure -M:deploy
+clojure -X:deploy
echo "Released $VERSION"
-
-rm *.pom.asc \ No newline at end of file
diff --git a/src/com/github/ivarref/yoltq.clj b/src/com/github/ivarref/yoltq.clj
index 3164020..03a364f 100644
--- a/src/com/github/ivarref/yoltq.clj
+++ b/src/com/github/ivarref/yoltq.clj
@@ -17,7 +17,6 @@
(defonce ^:dynamic *running?* (atom false))
(defonce ^:dynamic *test-mode* false)
-
(def default-opts
(-> {; Default number of times a queue job will be retried before giving up
; Can be overridden on a per consumer basis with
@@ -79,7 +78,8 @@
(-> (merge-with (fn [a b] (or b a))
{:running-queues (atom #{})
:start-execute-time (atom {})
- :system-error (atom {})}
+ :system-error (atom {})
+ :healthy? (atom nil)}
default-opts
(if *test-mode* old-conf (select-keys old-conf [:handlers]))
cfg)
@@ -148,6 +148,32 @@
(reset! threadpool nil))))))
+(defn healthy? []
+ (some->> @*config*
+ :healthy?
+ (deref)))
+
+(defn queue-stats []
+ (let [{:keys [conn]} @*config*
+ db (d/db conn)]
+ (->> (d/q '[:find ?e ?qname ?status
+ :in $
+ :where
+ [?e :com.github.ivarref.yoltq/queue-name ?qname]
+ [?e :com.github.ivarref.yoltq/status ?status]]
+ db)
+ (mapv (partial zipmap [:e :qname :status]))
+ (mapv #(select-keys % [:qname :status]))
+ (mapv (fn [qitem] {qitem 1}))
+ (reduce (partial merge-with +) {})
+ (mapv (fn [[{:keys [qname status]} v]]
+ (array-map
+ :qname qname
+ :status status
+ :count v)))
+ (sort-by (juxt :qname :status))
+ (vec))))
+
(comment
(do
(require 'com.github.ivarref.yoltq.log-init)
@@ -177,4 +203,4 @@
(start!)
(dotimes [x n]
@(d/transact conn [(put :q {:work 123})]))
- nil)))) \ No newline at end of file
+ nil))))
diff --git a/src/com/github/ivarref/yoltq/error_poller.clj b/src/com/github/ivarref/yoltq/error_poller.clj
index 77339f7..1268482 100644
--- a/src/com/github/ivarref/yoltq/error_poller.clj
+++ b/src/com/github/ivarref/yoltq/error_poller.clj
@@ -66,9 +66,13 @@
(defn do-poll-errors [{:keys [conn system-error
on-system-error
- on-system-recovery]
- :or {on-system-error (fn [] nil)
- on-system-recovery (fn [] nil)}
+ on-system-recovery
+ healthy?]
+ :or {on-system-error (fn []
+ (log/error "There are yoltq queues which have errors")
+ nil)
+ on-system-recovery (fn []
+ (log/info "Yoltq recovered"))}
:as config}]
(assert (some? conn) "expected :conn to be present")
(assert (some? system-error) "expected :system-error to be present")
@@ -79,8 +83,11 @@
(d/db conn)
u/status-error)
0)]
- (when (pos-int? error-count)
- (log/debug "poll-errors found" error-count "errors in system"))
+ (if (pos-int? error-count)
+ (do
+ (log/debug "poll-errors found" error-count "errors in system")
+ (reset! healthy? false))
+ (reset! healthy? true))
(let [{:keys [run-callback] :as new-state} (swap! system-error handle-error-count config (ext/now-ns) error-count)]
(when run-callback
(cond (= run-callback :error)
@@ -100,7 +107,7 @@
(when @running?
(do-poll-errors @config-atom))
(catch Throwable t
- (log/error t "unexpected error in poll-erros:" (ex-message t))
+ (log/error t "unexpected error in poll-errors:" (ex-message t))
nil)))
diff --git a/test/com/github/ivarref/yoltq/error_poller_test.clj b/test/com/github/ivarref/yoltq/error_poller_test.clj
index 2e0873e..18f0aa7 100644
--- a/test/com/github/ivarref/yoltq/error_poller_test.clj
+++ b/test/com/github/ivarref/yoltq/error_poller_test.clj
@@ -1,5 +1,5 @@
(ns com.github.ivarref.yoltq.error-poller-test
- (:require [clojure.test :refer :all]
+ (:require [clojure.test :refer [deftest is]]
[com.github.ivarref.yoltq.error-poller :as ep]
[clojure.tools.logging :as log]
[com.github.ivarref.yoltq.log-init :as logconfig]