This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-25
Channels
- # beginners (20)
- # boot (25)
- # cider (1)
- # cljs-dev (7)
- # cljsjs (1)
- # cljsrn (1)
- # clojure (79)
- # clojure-austin (2)
- # clojure-berlin (13)
- # clojure-dusseldorf (1)
- # clojure-germany (7)
- # clojure-russia (10)
- # clojure-serbia (1)
- # clojure-spec (18)
- # clojure-uk (4)
- # clojured (1)
- # clojurescript (90)
- # cursive (10)
- # datomic (7)
- # emacs (14)
- # hoplon (6)
- # luminus (16)
- # lumo (4)
- # numerical-computing (2)
- # om (25)
- # om-next (1)
- # onyx (11)
- # pedestal (10)
- # protorepl (1)
- # reagent (11)
- # remote-jobs (1)
- # ring (1)
- # rum (38)
- # spacemacs (5)
- # test-check (7)
- # untangled (122)
- # vim (1)
- # yada (8)
ballpark depending on your use case JWT might not be secure: http://cryto.net/~joepie91/blog/2016/06/13/stop-using-jwt-for-sessions/
I’m having a hard time getting transactions to work In database/core.clj I have something like this: (defstate ^:dynamic db :start (conman/connect! {:jdbc-url (env :database-url)}) :stop (conman/disconnect! db)) (conman/bind-connection db "sql/eventstore.sql") (defn within-transaction [operation] (conman/with-transaction [db] (do operation db)))
And is a separate file I have (db/within-transaction (fn[trn-conn] (append-to-event-stream trn-conn events))) where I explicitly specify the connection to every DB operation. But it seems that nothing ever gets persisted
All (easy) examples I can find start transactions in functions within database/core.clj but not in other files.
Can’t seem to get this working. Either records get persisted, but when an exception occurs, nothing gets reverted OR nothing gets persisted at all in a happy path scenario
could you try using the regular clojure.java.jdbc with-db-transaction
instead. You'd just have to pass the transactional connection to the query functions using it.
Yes, that does seem to do the trick
Also moving conman/with-transaction to the separate file seems to work as well
(conman/with-transaction [db] (append-to-event-stream aggregate-id aggregate-version events))
This was it doesn’t seem to be necessary to pass in the individual connection to the query functions
yeah I think it's the problem with the way the conman with-transaction macro is setup
It would be nice if somehow this could work: (defn within-transaction [operation] (conman/with-transaction [db] (do operation)))
Without passing a transactional connection. This would mean that it would somehow be picked up automagically.
Not sure if that would work though
I’m still a the noob level with the Luminus template
so this is what with-transaction
looks like:
(defmacro with-transaction [args & body]
`(clojure.java.jdbc/with-db-transaction [t-conn# ~(first args) ~@(rest args)]
(binding [~(first args) t-conn#]
~@body)))
I think that if you pass a fully qualified db
or have it referenced explicitly in the namespace you run with-transaction
, it should work as expected