@tolitius: got java.lang.RuntimeException: No such var: b/by-path
@bbss: interesting, https://github.com/boot-clj/boot/blob/master/boot/core/src/boot/core.clj#L999 which version of boot (`boot -V`) are you using?
Is there a best-practice for ensuring mount has started in the context of a lein task or run alias?
I'm guessing there's probably a better way than just starting off the exposed functions with (mount/start)
I suppose this is applicable to tests too… or really anything that exercises a namespace with a defstate
that doesn't come in through a -main
or something that can call (mount/start)
or is this really just indicative of me doing it wrong? 😄
@voxdolo: takes time to collect practices whether good or bad :simple_smile:, so such practice yet.. the way I see mount is used (and the way I use it) is I start it from either -main
or an app entry point (i.e. handler). there is also a way to hook it up to ring :init
(I can share an example if it is something that would help you).
since (mount/start)
is just a function, it can definitely be hooked up with lein or boot task of course
I've just set my handler itself to a defstate
since it has a middleware that depends on environment variables that may not be available during AoT… The handler is only referenced in one place, so I just call (mount/start) before that, and it seems to work fine thus far.
my issue is when I have some function that has external access that depends on state that I've encapsulated in mount
e.g. I have a lein migrate
task that's just a run alias, but it needs to reference a db-connection that's wrapped with mount
or similar for my tests that hit the database
those are invoked outside of those main entry points
fwiw though, it's totally possible I've got entirely the wrong idea about how to use mount
ah.. I see what you mean. hmm.. will need to think about it. I wonder whether it can be done with lein hooks of some sort. In my tests, I actually have (mount/start)
explicitly, moreover I only start states that are needed for those tests: i.e. (mount/start #'a/state #'b/state)
Ah, yeah… I'm putting this in an application after-the-fact to try to cure my AoT woes, so I've been using (mount/start)
as The Big Gun. I should probably be more selective about what I'm starting...
in my tests I was able to resolve it by just starting mount in the test helper function that wraps database calls in a transaction. And for now, I suppose I'll just pepper starts around in my tasks where necessary.
Thanks for mount, by the way :simple_smile:
sure, very welcome, thanks for feedback :simple_smile:
start around in my tasks where necessary
is probably the thing to do at the moment
if you think this can be done simpler, feel free to open an issue, and share the problem. some thoughts on the solution would also be very appreciated :simple_smile: