This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-11
Channels
- # aws (2)
- # babashka (11)
- # beginners (107)
- # calva (6)
- # cljsrn (18)
- # clojure (180)
- # clojure-australia (6)
- # clojure-europe (54)
- # clojure-losangeles (9)
- # clojure-nl (4)
- # clojure-uk (13)
- # clojureladies (1)
- # clojurescript (57)
- # clojureverse-ops (1)
- # consultantsdirectory (1)
- # cursive (48)
- # datomic (11)
- # defnpodcast (3)
- # degree9 (1)
- # deps-new (5)
- # depstar (21)
- # docker (2)
- # fulcro (15)
- # helix (32)
- # kaocha (1)
- # lsp (21)
- # malli (15)
- # meander (15)
- # news-and-articles (2)
- # nextjournal (1)
- # off-topic (42)
- # pathom (3)
- # podcasts (1)
- # polylith (73)
- # protojure (1)
- # re-frame (43)
- # reagent (1)
- # releases (1)
- # restql (1)
- # schema (1)
- # sci (1)
- # shadow-cljs (23)
- # spacemacs (7)
- # sql (5)
- # tools-deps (42)
- # vim (15)
- # xtdb (3)
I want to ensure that all my mutations run "synchronously" (one-at-a-time, to completion, across all threads) so I won't have to worry about some race conditions--does anybody have a recommended way of doing this? perhaps by wrapping my call to (parser env tx)
with some kind of mutex if tx
is a mutation?
@lgessler you can do something like that:
(def single-parser
(let [in (async/chan)]
(async/thread
(loop []
(when-let [{:keys [env tx out]} (async/<!! in)]
(async/>!! out (parser env tx))
(recur))))
in))
(comment
(defn handler
[req]
(let [out (async/chan)]
(async/>!! single-parser {:env env :tx tx :out out})
(async/!! out))))
Or try to use "wrap-mutation-plugin" to make it serial, but only if it is a mutation call
But why mutation races are a problem?
All that solutions will only work in a single machine, they do not scale👍 2
