Fork me on GitHub
#mount
<
2017-04-20
>
didibus06:04:51

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

ido12:04:31

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?

ido13:04:46

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

tolitius14:04:23

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

tolitius14:04:31

@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

tolitius14:04:46

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

tolitius14:04:04

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

arnout14:04:37

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

didibus16:04:59

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

didibus16:04:28

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

tolitius17:04:05

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

didibus17:04:33

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