This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-15
Channels
- # babashka (12)
- # beginners (88)
- # calva (6)
- # cider (4)
- # clerk (110)
- # clojure (18)
- # clojure-czech (1)
- # clojure-europe (26)
- # clojure-nl (1)
- # clojure-norway (7)
- # clojure-poland (8)
- # clojure-spain (2)
- # clojure-uk (2)
- # clojurescript (22)
- # cursive (11)
- # data-science (1)
- # datalevin (5)
- # datomic (35)
- # events (1)
- # fulcro (2)
- # gratitude (5)
- # helix (4)
- # hoplon (20)
- # hyperfiddle (52)
- # jobs (3)
- # lsp (1)
- # malli (48)
- # missionary (11)
- # off-topic (31)
- # practicalli (1)
- # reitit (7)
- # releases (1)
- # remote-jobs (7)
- # scittle (9)
- # shadow-cljs (7)
- # sql (11)
- # xtdb (5)
Hello. First try of missionary and datomic (peer) (https://gist.github.com/jeans11/845fdeedbf1257a8a3355d03f6bd4b31). Works with electric. Is this a correct way to consume the tx-report-queue
? I didn’t find a way to use observe
.
(defn latest-db [!conn]
(m/relieve {}
(m/observe
(fn [!]
(! (d/db !conn))
(let [q (d/tx-report-queue !conn)
t (Thread. ^Runnable
(fn []
(! (:db-after (.take ^Queue q)))
(recur)))]
(.start t)
#(do (.interrupt t) (.join t)
(d/remove-tx-report-queue !conn)))))))
this is the observe
way (warning - untested)How do the above approaches compare to this:
I also don't understand the reference to m/signal
(the upcoming primitive in missionary-next), can you spell it out for me please
datomic shares a single queue to all subscribers, so when there is more than one subscriber only one can observe a given change. m/signal acts as a proxy publisher enforcing a single subscription
For completeness, this is a modified version of Leo's latest-db
above, that silences log spam — JVM threads, when they terminate due to uncaught exception, the thread calls getUncaughtExceptionHandler which seems to have a JVM default impl that prints the exception to stderr. So we silence that.
Actually this seems to leak the thread on cancellation? I think we want to use m/via
per J’s original post, and pair it with the defonce
singleton pattern for correct broadcast to multiple sessions. That would mean cancellation is handled by m/via
, no threads ever die (since we're leveraging missionary threadpool) and therefore there shouldnt be any logspam, right?
Oh, the exception is signaling the thread is being harvested, i read it wrong and thought it was silencing the ThreatInterruptException that causes the thread to terminate in the first place (IIRC)