mount

2016-08-16T20:46:56.000659Z

Currently running into an issue with mount: I have a setup similar to the first example in the README:

(defstate conn :start (create-conn)
               :stop (disconnect conn))
However, create-conn might fail. In those cases, we log the issue, and return nil. However, mount sees that (create-conn) returned, and sets conn to the started state. When trying to stop conn, we see an exception because disconnect is a method provided by a protocol (we’ll call it IConn), and conn, being nil, obviously doesn’t implement that. I can fix this with a simple stopgap by saying something like (when conn (disconnect conn)), but I’d prefer a way to signify to mount that the connection wasn’t actually started. Is there a way to do this?

dm3 2016-08-16T20:48:11.000660Z

how do other states that depend on conn function if it's not started up?

2016-08-16T20:48:38.000661Z

They don’t, because they don’t function if conn is nil

2016-08-16T20:49:22.000662Z

I suppose just throwing an exception would be the simplest actual solution for what I want, which is that the world should stop and mount shouldn’t start up

dm3 2016-08-16T21:04:32.000663Z

yep

dm3 2016-08-16T21:05:06.000664Z

if there's no sensible way to recover - no point in doing anything

tolitius 2016-08-16T21:10:58.000665Z

@surreal.analysis: we do have an open discussion about failures on start: https://github.com/tolitius/mount/issues/50

tolitius 2016-08-16T21:11:11.000668Z

but I agree, :start just takes a function, if the function fails, it should throw, and if it does that mount won't start the state

tolitius 2016-08-16T21:13:06.000669Z

it is a bit simpler to delegate what's needed to an application function rather than a mount one, since this application could / should drive what is needed

tolitius 2016-08-16T21:14:04.000670Z

it could be just an exception, or some kind of a retry logic, or a default, etc.. application would know that a lot better than mount