New version of open-global

18 views
Skip to first unread message

Nicolas Buduroi

unread,
Aug 20, 2011, 1:04:24 AM8/20/11
to lobos-...@googlegroups.com
After discussing about an issue Pablo had with the open-global function, I decided to improve it to be able to re-open or leave alone a connection. I've made it so that the behavior of open-global remains unchanged if you don't modify your code with a new option to your db-specs.

Now, if you include the :unsafe key with a truthful value inside a db-spec, global connections opened with open-global will be closed then re-opened if the db-spec has changed, else it will do nothing. This way it smooth out the development process if you have to often edit the config namespace, which is where the open-global calls belong.

I wanted to keep the original behavior as it is (the same as ClojureQL) so if/when I get clojure.jdbc to include the connectivity namespace, it could be used by both libraries in a safe way.

The change is available in the latest SNAPSHOT release, don't hesitate to communicate any issues with this update.

J. Pablo Fernández

unread,
Aug 20, 2011, 5:25:12 AM8/20/11
to lobos-...@googlegroups.com
Did you push a new jar to Clojars?

Nicolas Buduroi

unread,
Aug 20, 2011, 2:54:33 PM8/20/11
to lobos-...@googlegroups.com
Yes

2011/8/20 J. Pablo Fernández <pup...@pupeno.com>

J. Pablo Fernández

unread,
Aug 21, 2011, 5:13:47 AM8/21/11
to lobos-...@googlegroups.com
Shouldn't it be the other way around? Why is unsafe to not run in a mode when an existing connection won't make the program crash?

Nicolas Buduroi

unread,
Aug 21, 2011, 3:06:22 PM8/21/11
to lobos-...@googlegroups.com
The unsafe option means that a connection could be closed by open-global. Although the scenario in which a safe connection must remains open while the associated db-spec has changed is quite improbable, I prefer to make sure that it can't happen by default. Be aware that raising an exception and crashing the application are totally different things.

2011/8/21 J. Pablo Fernández <pup...@pupeno.com>
Reply all
Reply to author
Forward
0 new messages