This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-14
Channels
- # adventofcode (36)
- # announcements (5)
- # atom-editor (2)
- # babashka (19)
- # beginners (98)
- # biff (7)
- # calva (25)
- # cider (1)
- # cljdoc (10)
- # clojure (70)
- # clojure-czech (1)
- # clojure-dev (14)
- # clojure-europe (79)
- # clojure-nl (1)
- # clojure-norway (8)
- # clojure-seattle (3)
- # clojure-uk (2)
- # clojurescript (28)
- # community-development (44)
- # core-typed (3)
- # cursive (2)
- # datalevin (5)
- # datascript (5)
- # datomic (1)
- # dev-tooling (12)
- # emacs (14)
- # honeysql (3)
- # humbleui (11)
- # introduce-yourself (1)
- # java (1)
- # kaocha (1)
- # lsp (3)
- # malli (21)
- # matcher-combinators (2)
- # nbb (7)
- # off-topic (15)
- # portal (12)
- # reitit (4)
- # releases (1)
- # shadow-cljs (59)
- # sql (8)
- # tree-sitter (3)
Har jeg liksom akkurat løst det vi trengte for 1.5fase commit over mongo og pg i ca 10 linjer Clojure?
(defn call-in-transaction
"A very rudimentary fn to ensure that either we persist to both databases or we don't persist to any of them. Only works on `org-db` and `org-ds` for now."
[ctx f]
(postgres/with-reused-transaction [_ (:org-ds ctx)]
(m/with-transaction (:org-db ctx)
(f)
(postgres/prepare-transaction! (:org-ds ctx) (gensym)))))
og
(defn prepare-transaction! [ds id]
(jdbc/execute! ds [(str "PREPARE TRANSACTION '" id "'")]))
Det var faktisk enda enklere:
(defn call-in-transaction
"A very rudimentary fn to ensure that either we persist to both databases or we don't persist to any of them. Only works on `org-db` and `org-ds` for now.
`f` is a fn that accepts a `ctx` as a parameter"
[{:keys [org-db org-ds] :as ctx} f]
(postgres/with-reused-transaction [tx org-ds]
(m/with-transaction org-db
(f (assoc ctx :org-ds tx)))))