I am am trying to setup LevelDB in a ring/compojure app, and looking for an idiomatic way to to access the opened db descriptor into each request.
For example:
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Opening LevelDB file in db/main")
(with-open [main-db (db/open "db/main")]
(println "Running server on port 3000")
(run-jetty #'web/app {:port 3000})))
How do you access the main-db
descriptor into the request handlers?
ie.:
(defroutes handler
(GET "/test" []
(db/put main-db (.getBytes "testKey2") (.getBytes "testValue2"))
"<h1>Hello World</h1>")
PS: I am using the leveldb-clj lib from Sedward and packaged it into a clojar: https://clojars.org/org.clojars.aircart/leveldb-clj