Skip to content

Commit

Permalink
feat: make healthcheck timeout configurable and extend from 1 to 3 sec
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricshih committed Feb 18, 2023
1 parent adf5a1e commit 23a0475
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ mirrors:
default_scheme: "https:"
firestore:
project_id: "*detect-project-id*"
healthcheck:
timeout_sec: 3
5 changes: 3 additions & 2 deletions controller/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
type HealthController struct{}

func (c *HealthController) Check(w http.ResponseWriter, r *http.Request) {
auth := config.Get().GetString("healthcheck.auth")
cfg := config.Get()
auth := cfg.GetString("healthcheck.auth")
if auth == "" {
http.Error(w, "Missing health check authorization", 401)
return
Expand All @@ -29,7 +30,7 @@ func (c *HealthController) Check(w http.ResponseWriter, r *http.Request) {
return
}
client := &http.Client{
Timeout: 1 * time.Second,
Timeout: time.Duration(cfg.GetInt("healthcheck.timeout_sec")) * time.Second,
}
for _, site := range sites {
for _, s := range site.Sources {
Expand Down

0 comments on commit 23a0475

Please sign in to comment.