mount

timgilbert 2016-07-21T18:30:31.000146Z

Hey, I have a slightly hypothetical question: I'm writing some shared library code, and in the ideal case I want it to work either with or without mount. Is there an easy way from my code determine if it's running inside mount? (Eg, whether (mount/start) has been called or not)

tolitius 2016-07-21T18:53:56.000151Z

@timgilbert: will this work for you?

dev=> (mount/running-states)
nil

dev=> (mount/start)
...
{:started ["#'app.conf/config" "#'app.db/conn" "#'app.www/nyse-app" "#'app.example/nrepl"]}
dev=>

dev=> (mount/running-states)
("#'app.conf/config" "#'app.db/conn" "#'app.www/nyse-app" "#'app.example/nrepl")

dev=> (mount/stop "#'app.db/conn")
INFO  app.db - disconnecting from  datomic:<mem://mount>
{:stopped ["#'app.db/conn"]}

dev=&gt; (mount/running-states)
("#'app.conf/config" "#'app.www/nyse-app" "#'app.example/nrepl")

tolitius 2016-07-21T18:56:36.000154Z

if yes, I put in in 0.1.11-SNAPSHOT

timgilbert 2016-07-21T18:59:39.000155Z

Oh, that's great, thanks!

timgilbert 2016-07-21T19:00:13.000156Z

I'll mess around with it and let you know. I'm still in the hammock phase of development right now

tolitius 2016-07-21T19:04:13.000157Z

sure, let me know. I think running-states is good to have regardless, so thanks for bringing it up. you could also get it via graph, e.g.:

dev=&gt; (require '[mount.tools.graph :as graph])
nil
dev=&gt; (map :name (filter (comp :started :status) (graph/states-with-deps)))
()

dev=&gt; (mount/start)
...
{:started ["#'app.conf/config" "#'app.db/conn" "#'app.www/nyse-app" "#'app.example/nrepl"]}

dev=&gt; (map :name (filter (comp :started :status) (graph/states-with-deps)))
("#'app.conf/config" "#'app.db/conn" "#'app.www/nyse-app" "#'app.example/nrepl")

tolitius 2016-07-21T19:04:26.000158Z

but (running-states) is a bit simpler

tolitius 2016-07-21T19:05:38.000159Z

i.e. (graph/states-with-deps) returns: https://github.com/tolitius/mount/issues/12#issuecomment-167150505