gocast icon indicating copy to clipboard operation
gocast copied to clipboard

Avoid inits

Open MatthiasReumann opened this issue 3 years ago • 1 comments

Changes

  • Closes #685
  • [Worker] cfg.Init() --> cfg.SetConfig() called in cmd/worker.go
  • [TUM-Live] config.Init() --> config.LoadConfig() called in cmd/tumlive.go
  • [TUM-Live] api.Init() --> api.ServeWorkerGRPC() called in cmd/tumlive.go

MatthiasReumann avatar Oct 11 '22 05:10 MatthiasReumann

Just had a look here out interest. The changes make sense to me, but I saw there are some more inits() not addressed by this PR. Are these OK? I think they could be also potentially removed.

  • This looks a bit problematic to me: https://github.com/joschahenningsen/TUM-Live/blob/095ca48c197349fcbcc06f8213d32912186d242e/tools/branding.go#L28
  • This one could be fine: https://github.com/joschahenningsen/TUM-Live/blob/815492a680744efc568197e6cb626268313d0a69/tools/realtime/channel_store.go#L13

Ah these must have been added after the merge of some later pull requests. At least the branding one is new. I will remove those two too. 👍🏻

MatthiasReumann avatar Oct 22 '22 07:10 MatthiasReumann

Just had a look here out interest. The changes make sense to me, but I saw there are some more inits() not addressed by this PR. Are these OK? I think they could be also potentially removed.

  • This looks a bit problematic to me: https://github.com/joschahenningsen/TUM-Live/blob/095ca48c197349fcbcc06f8213d32912186d242e/tools/branding.go#L28
  • This one could be fine: https://github.com/joschahenningsen/TUM-Live/blob/815492a680744efc568197e6cb626268313d0a69/tools/realtime/channel_store.go#L13

Removed the branding init function. The second one doesn't is fine, yes.

I've also added a list of initializers and the function initAll in cmd/tumlive.go. initAll basically iterates the global variable initializers calls the function at the beginning of execution.

MatthiasReumann avatar Oct 24 '22 06:10 MatthiasReumann