-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A reset function which will reset all the states even if there are errors. #63
Comments
To summarize the discussion with @tolitius:
The only open question is how to deal with states which fail to stop cleanly:
|
After thinking a bit more a separate API such as Pushed changes to
boot.user=> (defstate a :start 42 :stop (throw (RuntimeException. "BOOM")))
#'boot.user/a
boot.user=> (defstate b :start 1 :stop 2)
#'boot.user/b
boot.user=> (mount/start)
{:started ["#'boot.user/a" "#'boot.user/b"]}
boot.user=> a
42
boot.user=> b
1 boot.user=> (mount/stop)
#error {
:cause "BOOM"
:via
[{:type clojure.lang.ExceptionInfo
:message "could not stop [#'boot.user/a] due to"
...}]}
{:stopped ["#'boot.user/b"]} Since boot.user=> a
42
boot.user=> b
#object[mount.core.NotStartedState 0x2156abe2 "'#'boot.user/b' is not started (to start all the states call mount/start)"] However from mount's perspective We can now redefine boot.user=> (defstate a :start 42 :stop 34)
#'boot.user/a
boot.user=> (mount/start)
{:started ["#'boot.user/a" "#'boot.user/b"]}
boot.user=> a
42
boot.user=> b
1
boot.user=> (mount/stop)
{:stopped ["#'boot.user/b" "#'boot.user/a"]}
boot.user=> a
#object[mount.core.NotStartedState 0xa04c91c "'#'boot.user/a' is not started (to start all the states call mount/start)"]
boot.user=> b
#object[mount.core.NotStartedState 0x56b0c866 "'#'boot.user/b' is not started (to start all the states call mount/start)"] |
Situation I ran into:
This is interesting.
I defined a var with a
defstate
but made a mistake the first time around.;; not the same mistake but it will help elaborate what I’m trying to explain
(mount/start) ;; this works fine.
(mount/stop) ;; produces the error.
ClassCastException clojure.lang.Keyword cannot be cast to clojure.lang.IAtom clojure.core/reset! (core.clj:2273)
;; trying to re-define
conn
but keep running into the same error.A function to reset all the states/connections even if they produce error would be nice.
This was mentioned on Slack's mount channel by @tolitius .
"it might make sense to potentially have a some kind of
(mount/reset)
that could take params: i.e.(mount/reset :ignore-errors true)
. which, if well documented, could help in situations like this one."The text was updated successfully, but these errors were encountered: