Skip to content

Instantly share code, notes, and snippets.

@devn

devn/shim.clj Secret

Created October 8, 2014 19:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devn/3acd0c210113721eb024 to your computer and use it in GitHub Desktop.
Save devn/3acd0c210113721eb024 to your computer and use it in GitHub Desktop.
(ns an.aot.shim)
(def service-ns "an.aot.server")
(def handler* (atom nil))
(def handler (fn [request] (@handler* request)))
(defn init []
(require (symbol service-ns))
((resolve (symbol service-ns "init")))
(reset! handler* ((resolve (symbol service-ns "handler")))))
@devn
Copy link
Author

devn commented Dec 11, 2015

If you find yourself reading this, this is to avoid transitive AOT in a clojure application. This ensures that namespaces required from an.aot.server are not transitively AOT compiled.

@devn
Copy link
Author

devn commented Dec 11, 2015

Specifically, you'd use this for a ring application. In your leiningen project.clj:

  :ring {:handler an.aot.shim/handler
         :init an.aot.shim/init
         :port 3333
         :open-browser? false
         :nrepl {:start? true :port 9999}
         :stacktraces? false}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment