[Git][clojure-team/trapperkeeper-clojure][upstream] New upstream version 3.2.0

Jérôme Charaoui (@lavamind) gitlab at salsa.debian.org
Fri Oct 21 01:47:35 BST 2022



Jérôme Charaoui pushed to branch upstream at Debian Clojure Maintainers / trapperkeeper-clojure


Commits:
4cf00b79 by Jérôme Charaoui at 2022-10-20T20:15:28-04:00
New upstream version 3.2.0
- - - - -


8 changed files:

- − .gitmodules
- CHANGELOG.md
- locales/trapperkeeper.pot
- project.clj
- src/puppetlabs/trapperkeeper/app.clj
- src/puppetlabs/trapperkeeper/internal.clj
- test/puppetlabs/trapperkeeper/shutdown_test.clj
- test/puppetlabs/trapperkeeper/testutils/bootstrap.clj


Changes:

=====================================
.gitmodules deleted
=====================================
@@ -1,3 +0,0 @@
-[submodule "ext/pl-clojure-style"]
-	path = ext/pl-clojure-style
-	url = git://github.com/puppetlabs/pl-clojure-style.git


=====================================
CHANGELOG.md
=====================================
@@ -1,3 +1,30 @@
+## 3.2.0
+
+This is a minor feature release
+
+* Backward compatible changes to the signature of `puppetlabs.trapperkeeper.internal/shutdown!` function. Returns collection of exceptions caught during execution of shutdown sequence instead of nil.
+* Extend `stop` method of `puppetlabs.trapperkeeper.app/TrapperkeeperApp` protocol with an argument `throw?` to handle cases where exceptions in shutdown sequence should be rethrown.
+* Change default behavior of `puppetlabs.trapperkeeper.testutils.bootstrap` helper macroses to throw exception when shutdown finished abruptly.
+
+## 3.1.1
+
+This is a maintenance release
+
+* Updates to current clj-parent
+
+## 3.1.0
+
+This is a minor feature release
+
+* [PDB-4636](https://github.com/puppetlabs/trapperkeeper/pull/287) - support custom exit status/messages
+
+## 3.0.0
+
+This is a maintenance release
+
+* Updates to current clj-parent to clean up project.clj and update dependencies
+* Tests changes for readability and compatibility with Java11
+
 ## 2.0.1
 
 This is a maintenance release


=====================================
locales/trapperkeeper.pot
=====================================
@@ -7,7 +7,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: puppetlabs.trapperkeeper \n"
-"X-Git-Ref: 8aa311d5dc275d5f88dde3d6c4ab53e235bf32ec\n"
+"X-Git-Ref: 87802764a33be83d8ed7d02e60ed4ff791bdfc66\n"
 "Report-Msgid-Bugs-To: docs at puppet.com\n"
 "POT-Creation-Date: \n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
@@ -291,6 +291,10 @@ msgstr ""
 msgid "Error occurred during shutdown"
 msgstr ""
 
+#: src/puppetlabs/trapperkeeper/internal.clj
+msgid "Error during app shutdown!"
+msgstr ""
+
 #: src/puppetlabs/trapperkeeper/internal.clj
 msgid "Error during app buildup!"
 msgstr ""


=====================================
project.clj
=====================================
@@ -1,4 +1,4 @@
-(defproject puppetlabs/trapperkeeper "3.1.0"
+(defproject puppetlabs/trapperkeeper "3.2.0"
   :description "A framework for configuring, composing, and running Clojure services."
 
   :license {:name "Apache License, Version 2.0"
@@ -6,7 +6,7 @@
 
   :min-lein-version "2.9.0"
 
-  :parent-project {:coords [puppetlabs/clj-parent "4.0.1"]
+  :parent-project {:coords [puppetlabs/clj-parent "4.6.17"]
                    :inherit [:managed-dependencies]}
 
   ;; Abort when version ranges or version conflicts are detected in
@@ -50,8 +50,7 @@
                                      :sign-releases false}]]
 
   ;; Convenience for manually testing application shutdown support - run `lein test-external-shutdown`
-  :aliases {"cljfmt" ["with-profile" "+cljfmt" "cljfmt"]
-            "test-external-shutdown" ["trampoline" "run" "-m" "examples.shutdown-app.test-external-shutdown"]}
+  :aliases {"test-external-shutdown" ["trampoline" "run" "-m" "examples.shutdown-app.test-external-shutdown"]}
 
   ;; By declaring a classifier here and a corresponding profile below we'll get an additional jar
   ;; during `lein jar` that has all the code in the test/ directory. Downstream projects can then
@@ -59,10 +58,7 @@
   ;; code that we have.
   :classifiers [["test" :testutils]]
 
-  :profiles {:cljfmt {:plugins [[lein-cljfmt "0.5.0"]]
-                      :parent-project {:path "ext/pl-clojure-style/project.clj"
-                                       :inherit [:cljfmt]}}
-             :dev {:source-paths ["examples/shutdown_app/src"
+  :profiles {:dev {:source-paths ["examples/shutdown_app/src"
                                   "examples/java_service/src/clj"]
                    :java-source-paths ["examples/java_service/src/java"]
                    :dependencies [[puppetlabs/kitchensink :classifier "test"]]}


=====================================
src/puppetlabs/trapperkeeper/app.clj
=====================================
@@ -38,5 +38,5 @@
                                  "occurred, return the input parameter."))
   (init [this] "Initialize the services")
   (start [this] "Start the services")
-  (stop [this] "Stop the services")
-  (restart [this] "Stop and restart the services"))
\ No newline at end of file
+  (stop [this] [this throw?] "Stop the services")
+  (restart [this] "Stop and restart the services"))


=====================================
src/puppetlabs/trapperkeeper/internal.clj
=====================================
@@ -448,24 +448,36 @@
     (shutdown-on-error [this svc-id f] (shutdown-on-error* shutdown-reason-promise app-context svc-id f))
     (shutdown-on-error [this svc-id f on-error] (shutdown-on-error* shutdown-reason-promise app-context svc-id f on-error))))
 
-(schema/defn ^:always-validate shutdown!
+(schema/defn ^:always-validate shutdown! :- [Throwable]
   "Perform shutdown calling the `stop` lifecycle function on each service,
-   in reverse order (to account for dependency relationships)."
+   in reverse order (to account for dependency relationships).
+   Returns collection of exceptions thrown during shutdown sequence execution."
   [app-context :- (schema/atom a/TrapperkeeperAppContext)]
   (log/info (i18n/trs "Beginning shutdown sequence"))
   (let [{:keys [ordered-services shutdown-channel lifecycle-worker]} @app-context
-        shutdown-fn (fn [] (doseq [[service-id s] (reverse ordered-services)]
-                             (try
-                               (run-lifecycle-fn! app-context s/stop "stop" service-id s)
-                               (catch Exception e
-                                 (log/error e (i18n/trs "Encountered error during shutdown sequence"))))))]
+        errors-chan (async/promise-chan)
+        shutdown-fn (fn [] (let [results
+                                 (doall
+                                  (keep
+                                   (fn [[service-id s]]
+                                     (try
+                                       (run-lifecycle-fn! app-context s/stop "stop" service-id s)
+                                       nil
+                                       (catch Exception e
+                                         (log/error e (i18n/trs "Encountered error during shutdown sequence"))
+                                         e)))
+                                   (reverse ordered-services)))]
+                             (async/put! errors-chan results)))]
     (log/trace (i18n/trs "Putting shutdown message on shutdown channel."))
     (async/>!! shutdown-channel {:type :shutdown
                                  :task-function shutdown-fn})
     ;; wait for the channel to send us the return value so we know it's done
     (log/trace (i18n/trs "Waiting for response to shutdown message from lifecycle worker."))
     (if (not (nil? (async/<!! lifecycle-worker)))
-      (log/info (i18n/trs "Finished shutdown sequence"))
+      (do
+        (log/info (i18n/trs "Finished shutdown sequence"))
+        ;; deliver errors from stopped services if any
+        (async/<!! errors-chan))
       ;; else, the read from the channel returned a nil because it was closed,
       ;; indicating that there was already a shutdown in progress, and thus the
       ;; redundant shutdown request was ignored
@@ -606,8 +618,14 @@
         (inc-restart-counter! this)
         this)
       (a/stop [this]
-        (shutdown! app-context)
-        this)
+        (a/stop this false))
+      (a/stop [this throw?]
+        (let [errors (shutdown! app-context)]
+          (if (and throw? (seq errors))
+            (let [msg (i18n/trs "Error during app shutdown!")]
+              (log/error msg)
+              (throw (ex-info msg {:errors errors})))
+            this)))
       (a/restart [this]
         (try
           (run-lifecycle-fns app-context s/stop "stop" (reverse ordered-services))


=====================================
test/puppetlabs/trapperkeeper/shutdown_test.clj
=====================================
@@ -62,7 +62,8 @@
           app               (bootstrap-services-with-empty-config [test-service broken-service])]
       (is (false? @shutdown-called?))
       (logging/with-test-logging
-        (internal/shutdown! (app-context app))
+        (let [errors (internal/shutdown! (app-context app))]
+          (is (= '("dangit") (map #(.getMessage ^Throwable %) errors))))
         (is (logged? #"Encountered error during shutdown sequence" :error)))
       (is (true? @shutdown-called?)))))
 


=====================================
test/puppetlabs/trapperkeeper/testutils/bootstrap.clj
=====================================
@@ -22,7 +22,7 @@
        (try
          ~@body
          (finally
-           (tk-app/stop ~app))))))
+           (tk-app/stop ~app true))))))
 
 (defn bootstrap-services-with-cli-data
   [services cli-data]
@@ -37,7 +37,7 @@
        (try
          ~@body
          (finally
-           (tk-app/stop ~app))))))
+           (tk-app/stop ~app true))))))
 
 (defn bootstrap-services-with-cli-args
   [services cli-args]
@@ -51,7 +51,7 @@
        (try
          ~@body
          (finally
-           (tk-app/stop ~app))))))
+           (tk-app/stop ~app true))))))
 
 (defn bootstrap-services-with-empty-config
   [services]
@@ -64,7 +64,7 @@
        (try
          ~@body
          (finally
-           (tk-app/stop ~app))))))
+           (tk-app/stop ~app true))))))
 
 (defn bootstrap-with-empty-config
   ([]



View it on GitLab: https://salsa.debian.org/clojure-team/trapperkeeper-clojure/-/commit/4cf00b798af4520f42900dfad85cb6e3532ad451

-- 
View it on GitLab: https://salsa.debian.org/clojure-team/trapperkeeper-clojure/-/commit/4cf00b798af4520f42900dfad85cb6e3532ad451
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20221021/1d7d0d9d/attachment.htm>


More information about the pkg-java-commits mailing list