Hello Folks,
I am a complete Clojure newbie and trying to achieve something pretty
simple and looking for an idiomatic, if I can make it work at all, way to
do it.
My issue is I need to retain the LevelDB descriptor and share it between
requests, LevelDB is already thread-safe.
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})))
Now, how can I access that main-db descriptor in my requests handlers?
This, obviously won't work, as main-db is not defined in web/app:
(GET "/test" []
(db/put main-db (.getBytes "testKey2") (.getBytes "testValue2"))
"<h1>Hello World</h1>")
PS: If it helps anyone for setup, I have made a Clojar for the LevelDB JNI
Clojure wrapper based on Sedward's:
https://clojars.org/org.clojars.aircart/leveldb-clj
Thanks in advance for your insight/help!
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.