mount

lfn3 2016-02-24T20:28:45.000128Z

So I’m not sure if this is a reasonable question or not… but has anyone dealt with the case where a defstate fails to start? In my case it might be totally reasonable for a thing to not start, in which case I just don’t want to use it, but there might be other cases where the entire app should stop. Has anyone else thought about/dealt with this stuff?

tolitius 2016-02-24T20:31:33.000129Z

@lfn3: say we have 3 states A, B and a C. on (mount/start), B failed to start. Are you saying in some case it is ok to ignore this fact, and just use an application with just A and C?

lfn3 2016-02-24T20:32:52.000130Z

@tolitius: Yeah that’s correct, but some functionality should be disabled when B fails to start.

tolitius 2016-02-24T20:33:22.000131Z

@lfn3: what is C depends on B?

lfn3 2016-02-24T20:34:07.000132Z

@tolitius: Seems like the behaviour should be transitive, right? If B fails then C should also fail.

tolitius 2016-02-24T20:35:02.000133Z

hm.. can you give a use case where this is needed? :simple_smile:

tolitius 2016-02-24T20:35:21.000134Z

transitive failures are not simple

tolitius 2016-02-24T20:36:13.000135Z

if you don't need the state that could fail (and app is ok with it), can't you just start with "(start-without B)"?

lfn3 2016-02-24T20:36:32.000136Z

Agreed, but I’m thinking more if B fails to start and C uses B in it’s :start method then transitive-ness will be handled 'auto-magically'.

tolitius 2016-02-24T20:37:01.000137Z

auto-magic is auto-complex :simple_smile:

tolitius 2016-02-24T20:37:20.000138Z

I am thinking...

lfn3 2016-02-24T20:38:45.000139Z

The thing is we’d like to try and start with B but if it fails, that’s fine, we just want to have that affect other parts of the application (change routing, for instance)

tolitius 2016-02-24T20:39:06.000140Z

if B is ok to fail, could it then program this behavior in its start method?

(defn start-b []
  (try ...
    (catch Throwable t
      :dafault-b-value)))
(defstate b :start (start-b))

lfn3 2016-02-24T20:39:35.000141Z

Yeah that’s where I was headed as well.

tolitius 2016-02-24T20:40:17.000142Z

another one is:

(mount/start-without "B")
(mount/start)

tolitius 2016-02-24T20:40:47.000144Z

then if (mount/start) fails, you are still ok

tolitius 2016-02-24T20:41:21.000145Z

unless you can't really start without B because C depends on it... then:

(mount/start-without "B" "C")
(mount/start)

tolitius 2016-02-24T20:42:14.000146Z

but this is interesting case. can you create an github issue for this? would be really helpful if you provided a real use case where it is needed

lfn3 2016-02-24T20:42:59.000147Z

Yeah no problem, I’ll put something together.

tolitius 2016-02-24T20:43:21.000148Z

great thanks!