What if I want to run a select query in the middle of a transaction?
On Thursday, August 1, 2013 3:33:29 AM UTC+9, tbc++ wrote:
DB work is a IO operation, and IO shouldn't be done inside a go block (go
blocks use limited thread pools).
So what about something like this?
(defn handle-db
These are interesting code listings and questions, but they conflate the
syntactic detail that core.async's go is implemented as a macro, with the
semantic intention to support designs around lightweight data flow between
independent code blocks.
It might be of value to check out Go, the
(defonce ^ExecutorService db-thread-pool (Executors/newFixedThreadPool 8))
(defn db-thread-call
[f]
(let [c (chan 1)]
(.execute db-thread-pool
(fn []
(let [ret (try
(f)
(catch Throwable t
On Wed, Jul 31, 2013 at 10:29 AM, Alice dofflt...@gmail.com wrote:
(go
(jdbc/db-transaction [t-con db-spec]
(! (insert-async! t-con :fruit {:name apple}
Does this work:
(jdbc/db-transaction [t-con db-spec]
(go
(! (insert-async! t-con :fruit {:name apple}
--
Sean A
It doesn't produce a compile time error but I think it's not the correct
code because the transaction can be committed while insert-async! is still
executing.
On Thursday, August 1, 2013 2:46:29 AM UTC+9, Sean Corfield wrote:
On Wed, Jul 31, 2013 at 10:29 AM, Alice doff...@gmail.com
Why not use !! ?
Timothy
On Wed, Jul 31, 2013 at 11:58 AM, Alice dofflt...@gmail.com wrote:
It doesn't produce a compile time error but I think it's not the correct
code because the transaction can be committed while insert-async! is still
executing.
On Thursday, August 1, 2013 2:46:29 AM
I have an async http handler and I don't want it to consume a thread.
On Thursday, August 1, 2013 3:16:52 AM UTC+9, tbc++ wrote:
Why not use !! ?
Timothy
On Wed, Jul 31, 2013 at 11:58 AM, Alice doff...@gmail.com
javascript:wrote:
It doesn't produce a compile time error but I think it's
DB work is a IO operation, and IO shouldn't be done inside a go block (go
blocks use limited thread pools).
So what about something like this?
(defn handle-db [chan]
(thread
(while true
(let [[data result] (! c)]
(run-db-transaction-as-normal data)
(! result
(defn insert-async!
[ args]
(db-thread
(try
(apply jdbc/insert! args)
(catch Throwable t
t
db-thread is a macro that runs the body in a fixed thread pool, so IO isn't
done inside a go block.
On Thursday, August 1, 2013 3:33:29 AM UTC+9, tbc++ wrote:
DB work is
On Wed, Jul 31, 2013 at 10:58 AM, Alice dofflt...@gmail.com wrote:
It doesn't produce a compile time error but I think it's not the correct
code because the transaction can be committed while insert-async! is still
executing.
Right. I was just showing how to avoid the compile error (because
10 matches
Mail list logo