3 ms·
Clojure does allow you to remove symbol mappings from a namespace. The only problem with deploying via the REPL is that there isn't a function for atomically de
by weavejester 17y ago
Clojure does allow you to remove symbol mappings from a namespace. The only problem with deploying via the REPL is that there isn't a function for atomically deploying a namespace, or set of namespaces. I suspect one would have to use a global lock to pause all request-handling threads for the second or so Clojure needs to teardown and reload all its libraries.
- sunkencity 17y agoLooking into this, you mean using (use 'mynamespace :reload) instead of C-c C-k - that is a good idea! It should be trivial to write a ring middleware to reload everything between every request (for a railsy development environment) maybe a version for production use that checks all files for changes every 1 minute or so.
- weavejester 17y agoI think it's a touch trickier than that. As far as I'm aware, a reload cannot remove namespace mappings; it can just add new ones and overwrite existing ones. So with continual reloads you might find yourself with old deprecated functions cluttering up your namespace. Another problem is that Clojure loads up namespaces sequentially, rather than atomically. So you might end up with an a new version of one function calling the old version of another. In order for your reloading middleware to be robust, I suspect you'd have to (1) wait for any existing request-handling threads to finish, (2) suspend any new request-handling threads, (3) reload your namespaces, (4) resume any suspended request threads.