Fork me on GitHub
#datomic
<
2016-10-16
>
achesnais05:10:15

So I’m building up a spec to validate an input map, and one key of that map is a datomic database. For this reason I’ve written a spec that checks for the datomic.db.Db type. Because I want to be able to exercise etc. my spec, I’ve also written it with a generator:

(s/def :datomic/db
  (s/with-gen
    #(instance? datomic.db.Db %)
    #(sgen/return (let [uri  "datomic:"
                        conn (partial d/connect uri)]
                    (d/create-database uri) 
                    (d/db (conn))))))

achesnais05:10:17

Is this a good way to go? And how would garbage collection work on the memory databases generated via exercise? Since the memory db doesn’t seem linked to a specific var but is created indirectly via a uri, is there a risk that I may fill up my memory with this?

achesnais05:10:28

Or would the fact that I’m reusing the same uri preventing multiple dbs from being created?

robert-stuttaford07:10:59

@achesnais datomic connections cache, so you’d only pay for one in that instance. i believe it won’t gc until you d/release it

achesnais07:10:22

Makes sense 🙂