Skip to content

Commit

Permalink
Use updated daemon implementation from wunderboss
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias committed Oct 6, 2015
1 parent d9ee61b commit 550ca0d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
22 changes: 14 additions & 8 deletions core/src/immutant/daemons.clj
Expand Up @@ -17,9 +17,10 @@
your application."
(:require [immutant.internal.options :as o])
(:import org.projectodd.wunderboss.WunderBoss
[org.projectodd.wunderboss.singleton
SingletonContext
SingletonContext$CreateOption]))
[org.projectodd.wunderboss.ec
DaemonContext
DaemonContext$CreateOption
DaemonContext$StopCallback]))

(defn singleton-daemon
"Sets up a highly-available singleton daemon.
Expand All @@ -37,9 +38,14 @@
If used outside of WildFly, or in a WildFly instance not in a cluster,
it behaves as if the cluster size is 1, and starts immediatey."
[daemon-name start-fn stop-fn]
(doto ^SingletonContext (WunderBoss/findOrCreateComponent SingletonContext
(name daemon-name)
(o/extract-options {:daemon true, :daemon-stop-callback stop-fn}
SingletonContext$CreateOption))
(.setRunnable start-fn)
(doto ^DaemonContext
(WunderBoss/findOrCreateComponent DaemonContext
(name daemon-name)
;; TODO: expose :stop-timeout
(o/extract-options {:singleon true}
DaemonContext$CreateOption))
(.setAction start-fn)
(.setStopCallback (reify DaemonContext$StopCallback
(notify [_ _]
(stop-fn))))
.start))
2 changes: 1 addition & 1 deletion core/test/immutant/daemons_test.clj
Expand Up @@ -28,7 +28,7 @@
#(deliver stopped-p :stopped))
(is (= :started (deref started-p 1000 :failure)))
;; confirm we're on the right thread
(is (re-find #"singleton-thread\[foo\]" @thread-a))
(is (re-find #"daemon-thread\[foo\]" @thread-a))
(WunderBoss/shutdownAndReset)
;; confirm stop fn is called
(is (= :stopped (deref stopped-p 1000 :failure)))))
2 changes: 1 addition & 1 deletion project.clj
Expand Up @@ -92,7 +92,7 @@
environ "1.0.0"

;; org.projectodd.wunderboss "0.9.0"
org.projectodd.wunderboss "1.x.incremental.289"
org.projectodd.wunderboss "1.x.incremental.290"
;; org.projectodd.wunderboss "0.9.1-SNAPSHOT"

org.immutant :version
Expand Down

0 comments on commit 550ca0d

Please sign in to comment.