Good morning!
Is there a recommended way to define a stateful thing with mount when in dev and define it without mount while in prod?
This is about the best I can come up with, but it's obviously poor practice to use def within an if:
(if (= env :local)
;; defines conn with mount/defstate to make it easily reloadable
(mount/defstate conn
:start (d/connect db-url)
:stop (d/release conn))
;; defines con just as a top-level variable for use in prod
(def conn (d/connect db-url)))Or is this even something I should be bothering with? I'm coming from the standpoint that this is a development tool and shouldn't be used in prod, but maybe that's a misconception.
There is no reason to avoid using mount in prod. It's definitely not meant as a dev-only tool.
@andyfry01 what would be the reason not to do this for all envs?
(defstate conn :start (d/connect db-url)
:stop (d/release conn))I .... uh, don't know 😂 @tolitius What I'm using it for right now is to reset DB connections when I need to throw away and re-bootsteap a DB. That need is what brought me to mount, and at least right now I don't know what I'd use it for in production, or what I'd need it for. I'm sure I'll discover that utility soon though. Thanks for the clarifications.