Improve reliability and quality of the system namespace #1

Merged
seabass merged 4 commits from seabass/matchbot:system-improvements into master 2022-03-26 15:05:32 +01:00
1 changed files with 1 additions and 6 deletions
Showing only changes of commit fecd09c656 - Show all commits

View File

@ -34,11 +34,6 @@
(yaml/parse-stream datafile))
(catch Exception e nil)))
(defn system []
{:config nil
:state nil
:irc nil})
(defn start [system]
sm2n marked this conversation as resolved Outdated
Outdated
Review

start doesn't actually use its input as far as I can tell? I think it'd be better to use _ as the binding name here since that is the case.

`start` doesn't actually use its input as far as I can tell? I think it'd be better to use _ as the binding name here since that is the case.

I was imagining that, in the future, this could be used to pass custom options to a single instance for development purposes, and also eventually for the main function to read the config and pass it in rather than system/start doing it by itself. Do you have any preference here? For now, yes, I agree it would be better to use _ as the binding name.

I was imagining that, in the future, this could be used to pass custom options to a single instance for development purposes, and also eventually for the main function to read the config and pass it in rather than `system/start` doing it by itself. Do you have any preference here? For now, yes, I agree it would be better to use `_` as the binding name.
Outdated
Review

No, I don't have a preference here. I think what you said makes sense with regards to custom options etc. Feel free to mark this resolved.

No, I don't have a preference here. I think what you said makes sense with regards to custom options etc. Feel free to mark this resolved.

Resolved in commit 91cbdb69da.

Resolved in commit 91cbdb69da.
(let [config (load-config "config.yaml")
state (atom (load-state (:data-file config)))
@ -58,7 +53,7 @@
(defn restart [system-var]
(do
(alter-var-root system-var stop)
(alter-var-root system-var (constantly system))
(alter-var-root system-var (constantly nil))
sm2n marked this conversation as resolved Outdated
Outdated
Review

No reason for this either, I think? As the system value isn't used for start, and running stop multiple times is safe.

No reason for this either, I think? As the system value isn't used for `start`, and running `stop` multiple times is safe.

I've just made commit 91cbdb69da - is this what you had in mind?

I've just made commit 91cbdb69da - is this what you had in mind?
(alter-var-root system-var start)))
(defn -main [& args]