-
Notifications
You must be signed in to change notification settings - Fork 73
Refactor main.go, to use a config struct instead of global vars #18
Comments
We should probably support falling back to the env vars at least for a period of time. This would make the transition to new config format easier. |
For some context on this issue and some of the following ones, this issue is meant to implement something like this: type Config struct {
listenAddr string
verbose bool
processDuration prometheus.Histogram
processesCurrent prometheus.Gauge
errCounter *prometheus.CounterVec
rnr *runner
}
func (cfg *Config) handleWebhook(w http.ResponseWriter, req *http.Request) {
cfg.rnr.run(...)
}
func main() {
c := Config{
...
}
http.HandleFunc("/", c.handleWebhook)
} We're passing the same function (now a method) to Then in issue #20, we can populate values in the Issue #24 talks about adding functionality for providing alarm data to a command via STDIN. We can make it so that the |
* resolves #18 * handleWebhook actually records prometheus metrics (available via the `/metrics` endpoint) for itself now * Also add test cases for handleWebhook, handleHealth. resolves #19 * Checks http responses * Check metrics observed by handleWebhook * HTTP server can be stopped independently of program, so we have the option of running instances of it in test cases. * Test cases use a random available TCP port to bind to, HTTP if server is run * Add signal-handling, to gracefully shut down HTTP server when program receives SIGINT (give existing requests 4 seconds to finish) * Connect command stdout, stderr directly to log writer
* Switch to using config struct for program configuration * resolves #18 * handleWebhook actually records prometheus metrics (available via the `/metrics` endpoint) for itself now * Also add test cases for handleWebhook, handleHealth. resolves #19 * Checks http responses * Check metrics observed by handleWebhook * HTTP server can be stopped independently of program, so we have the option of running instances of it in test cases. * Test cases use a random available TCP port to bind to, HTTP if server is run * Add signal-handling, to gracefully shut down HTTP server when program receives SIGINT (give existing requests 4 seconds to finish) * Connect command stdout, stderr directly to log writer * Don't attempt to execute the command, if we weren't able to decode prometheus alarm data properly * Have the fake request for handleHealth match the path being used to route requests to it in real http server. It's a noop, but makes the test look more consistent~
This will
handleWebhook
easier to testThe text was updated successfully, but these errors were encountered: