mount

2016-01-20T00:19:15.000385Z

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

tolitius 2016-01-20T14:15:03.000387Z

@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?

voxdolo 2016-01-20T20:20:49.000390Z

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

voxdolo 2016-01-20T20:23:54.000391Z

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

voxdolo 2016-01-20T20:36:48.000392Z

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)

voxdolo 2016-01-20T20:37:00.000393Z

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

tolitius 2016-01-20T20:45:14.000394Z

@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

voxdolo 2016-01-20T20:47:41.000395Z

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.

voxdolo 2016-01-20T20:48:10.000396Z

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

voxdolo 2016-01-20T20:48:38.000397Z

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

voxdolo 2016-01-20T20:48:50.000398Z

or similar for my tests that hit the database

voxdolo 2016-01-20T20:49:00.000399Z

those are invoked outside of those main entry points

voxdolo 2016-01-20T20:49:44.000400Z

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

tolitius 2016-01-20T20:53:14.000401Z

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)

voxdolo 2016-01-20T20:54:11.000402Z

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

voxdolo 2016-01-20T20:55:57.000403Z

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.

voxdolo 2016-01-20T20:56:32.000404Z

Thanks for mount, by the way :simple_smile:

tolitius 2016-01-20T20:59:51.000405Z

sure, very welcome, thanks for feedback :simple_smile:

tolitius 2016-01-20T21:00:07.000406Z

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

tolitius 2016-01-20T21:01:10.000408Z

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: