Repository navigation
feat(routing)!: the server listens as its config says - #12
arjendevos wants to merge 5 commits into
Conversation
Run read HOST, PORT and SHUTDOWN_TIMEOUT from the environment itself. It now takes config.Server, handed to routing.WithConfig, which it needs: without one, Run fails with ErrNoConfig. An empty host is 0.0.0.0, port 0 is 80, and no timeout is 30s, as before. BREAKING CHANGE: routing.WithConfig is required to Run.
|
|
||
| func WithHealth(endpoint string) Option { | ||
| return func(r *Routing) { | ||
| r.HealthEndpoint = endpoint |
There was a problem hiding this comment.
i think this should be moved to the config the healhtendpoint
There was a problem hiding this comment.
same for the trustedplatform etc
There was a problem hiding this comment.
Moved to config.Server.HealthEndpoint in 2fe5438; WithHealth is gone.
There was a problem hiding this comment.
Same for config.Server.TrustedPlatform. Whether failed responses show their error went there too (ShowErrors, in #13) instead of a package-level switch.
| ) | ||
|
|
||
| // ErrNoConfig is Run without WithConfig. | ||
| var ErrNoConfig = errors.New("[routing] no config: pass routing.WithConfig") |
There was a problem hiding this comment.
i dont like this being a var
There was a problem hiding this comment.
Gone: the error is returned inline, here and in queueing, cache and redis.
| if h := os.Getenv("HOST"); h != "" { | ||
| host = h | ||
| host, port := r.Config.Host, r.Config.Port | ||
| if host == "" { |
There was a problem hiding this comment.
iwould do host, port := "0.0.0.0", 80 and then the if r.config.host {}?
There was a problem hiding this comment.
Done, and the shutdown timeout the same way.
… the server config Both are how the server is set up, like its host and port, so they sit in config.Server instead of options of their own. The missing config error is returned inline and the defaults are set before the config overrides them.
|
Folded into #18. |
Stacked on #11.
Routing.RunreadHOST,PORTandSHUTDOWN_TIMEOUTfrom the environment itself, and the health endpoint and trusted platform were options of their own. All of it is nowconfig.Server, handed torouting.WithConfig, as queueing takesconfig.Queue:WithConfigis required:Runwithout it fails. Building the engine (Engine(), as tests do) does not need it.0.0.0.0, port0is80, no timeout is 30s.Breaking: pass
routing.WithConfigwith whatHOST,PORTandSHUTDOWN_TIMEOUTused to say;routing.WithHealthandrouting.WithTrustedPlatformare gone, for the config'sHealthEndpointandTrustedPlatform.Tested: the shutdown test (moved under
tests/routing) now listens from the config, and new tests coverRunwithout one and the health endpoint from the config.