Fork me on GitHub
#mount
<
2016-01-20
>
bbss00:01:15

@tolitius: got java.lang.RuntimeException: No such var: b/by-path

voxdolo20:01:49

Is there a best-practice for ensuring mount has started in the context of a lein task or run alias?

voxdolo20:01:54

I'm guessing there's probably a better way than just starting off the exposed functions with (mount/start)

voxdolo20:01:48

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)

voxdolo20:01:00

or is this really just indicative of me doing it wrong? 😄

tolitius20:01:14

@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

voxdolo20:01:41

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.

voxdolo20:01:10

my issue is when I have some function that has external access that depends on state that I've encapsulated in mount

voxdolo20:01:38

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

voxdolo20:01:50

or similar for my tests that hit the database

voxdolo20:01:00

those are invoked outside of those main entry points

voxdolo20:01:44

fwiw though, it's totally possible I've got entirely the wrong idea about how to use mount

tolitius20:01:14

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)

voxdolo20:01:11

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...

voxdolo20:01:57

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.

voxdolo20:01:32

Thanks for mount, by the way simple_smile

tolitius20:01:51

sure, very welcome, thanks for feedback simple_smile

tolitius21:01:07

start around in my tasks where necessary is probably the thing to do at the moment

tolitius21:01:10

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