That error sounds familiar, but I don't remember why 🙂
Very odd that it seems to be running your start function on stop
> you'll need to make sure they're not coming from edn as symbols (e.g. by just assoc it on in your code portion). ^ this isn't relevant with the later sha I think 🙂
Yeah, I'll try to find the time to dive into the problem next week.
Ah, I see the problem
http-kit returns a function, so clip is trying to reload it for you :)
@flowthing This solved it:
(def other-system-config
{:components
{:handler `{:start (handler {})}
:http '{:start (org.httpkit.server/run-server (clip/ref :handler) {:port 8080})
:stop (this)}}
:reloads
`{clojure.lang.Fn repl/relodable-fn
:http nil}})
Ah, of course! Thanks, I’ll try that out.
When this hits master, API might actually be more like:
(def other-system-config
{:components
{:handler `{:start (handler {})}
:http '{:start (org.httpkit.server/run-server (clip/ref :handler) {:port 8080})
:stop (this)
:reload nil}}
:reloads
`{clojure.lang.Fn repl/relodable-fn}})
As I think it's important to localize how the reload works. On the fence about whether matchers should be predicate based or some such.Could definitely see some kind of "convention" where a team does:
(def other-system-config
{:components
{:handler/a `{:start (handler {})}
:handler/b `{:start (handler {})}
:router '{:start [["/about" (clip/ref :handler/a)]
["/foobar" (clip/ref :handler/b)]]}
:http '{:start (org.httpkit.server/run-server (clip/ref :handler) {:port 8080})
:stop (this)
:reload nil}}
:reloads
{(fn [k _v] (= "handler" (namespace k))) repl/relodable-fn}})
General solution is good, but API is still open for debate.
Could also add some data to the exception when this happens too, and fall back onto the original. Not sure if stop should operate on the original item or the wrapped one either…