I'm using Datomic in several projects and it's time to move all the common code to a small utilities library.
One challenge is to deal with a shared database uri
, on which most operations depend, but must be set by the project using the library. I wonder if there is a well-established way to do this. Here are some alternatives I've thought about:
Dropping the
uri
symbol in the library and adding the uri as an argument to every function that accesses the databaseAltering it via
alter-var-root
, or similar mechanism, in an init functionKeeping it in the library as a dynamic var
*uri*
and overriding the value in a hopefully small adapter layer like(def my-url ...bla...)
(defn my-fun [args] (with-datomic-uri my-uri (apply library/my-fun args))
Keeping
uri
as an atom in the library