mount

2017-04-20T06:32:51.163796Z

Is there anything like danielz/system but for mount? I guess just a set of ready made defstates?

ido 2017-04-20T12:48:31.752320Z

Hey guys, I have a service which has so called 'modes'. The running mode is given by command line args. now each mode should start a certain subset of the states of the service. I used only to tell mount which states to run in each mode, but I suspect that this confuses mount about when computing the order in which the states should be started. I am I right in my assumption that proper starting order can only be done when start is called without args?

ido 2017-04-20T13:23:46.234395Z

...mmm or this is just me testing with lein run without lein clean and messing with compiling order?

tolitius 2017-04-20T14:20:23.194010Z

@colliderwriter I have not spec'ed mount yet, but if anybody else has any samples you are welcome to share

tolitius 2017-04-20T14:20:31.196084Z

@didibus Are you looking for something specific (i.e. how to start / stop a specific resource)? Any mount specific contributions to danielz/system are very welcome. One of the reasons "pre cooked" states are not there is because mount states usually have "no ceremony" compare to component and other state managing libs. The focus is mostly on actual functions within the resources: i.e. connect / disconnect, bind / unbind, etc.. vs. writing ceremony code around these functions

tolitius 2017-04-20T14:20:35.197311Z

@didibus Here is a comparison for example: https://gist.github.com/tolitius/7449fc5c6248c9c9f5ff

tolitius 2017-04-20T14:20:46.200801Z

@ido > proper starting order can only be done when start is called without args no exactly. the order is determined as defstates get compiled. In your case it seems you'd like to build states based on the runtime args before a call to (mount/start).

tolitius 2017-04-20T14:21:04.206106Z

@ido for example

(defn select-mode [{:keys [mode]}]
  (case mode
    :one (mount/only #{#'foo/a
	                   #'foo/b})
    :two (mount/only #{#'foo/c
	                   #'foo/d})
    :three (mount/only #{#'foo/a
                         #'foo/e
                         #'foo/z})
    #{}))

(defn -main [& args]
  (->> (parse-args args)
       select-mode
       (apply mount/start)))

arnout 2017-04-20T14:22:37.234136Z

@didibus Work on mount systems has been started some time ago: https://github.com/danielsz/system/pull/84

2017-04-20T16:43:59.805021Z

@arnout Ah, that's cool to know. I'll keep an eye out for it.

2017-04-20T16:46:28.845708Z

@tolitius I agree that mount states are pretty lightweight, but sometimes some state requires a lot of construction and destruction code within the start and stop. So for commonly used states like the components in system, it can save you a bit of time.

tolitius 2017-04-20T17:08:05.200330Z

@didibus yep, agree. would be good to have more contributions to danielz/system

2017-04-20T17:21:33.417589Z

If I've got some spare time, might contribute to that branch