Last active
February 11, 2019 22:36
-
-
Save magnars/5e36af346c3d6a47cf0c8e84252386b5 to your computer and use it in GitHub Desktop.
Suppress datomic transactions to prod from dev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn suppress-datomic-transactions-to-prod [config] | |
(when (str/starts-with? (:datomic-uri config) "datomic:ddb://") | |
(println "Warning! Suppressing transactions to production datomic from dev environment. Check your config.") | |
(let [the-conn (d/connect (:datomic-uri config))] | |
(alter-var-root (var datomic.api/transact) | |
(fn [transact] | |
(fn [conn txs] | |
(if (= conn the-conn) | |
(do (log/warn "Suppressed datomic transaction to production.") | |
(let [db (d/db conn)] (future {:db-after db :db-before db :tx-data nil}))) | |
(transact conn txs)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SQL and Cassndra users will be disappointed with these semantics. :-)