diff --git a/.golangci.yml b/.golangci.yml index a17d6a3..eb88fa9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -81,6 +81,7 @@ linters-settings: - github.com/go-chi/httplog/v2 - github.com/go-chi/chi/v5 - github.com/urfave/cli/v2 + - github.com/hashicorp/go-multierror issues: max-same-issues: 0 # unlimited diff --git a/go.mod b/go.mod index 8f72ca6..f010d0c 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/go-chi/chi/v5 v5.0.12 github.com/go-chi/httplog/v2 v2.0.9 github.com/go-http-utils/headers v0.0.0-20181008091004-fed159eddc2a + github.com/hashicorp/go-multierror v1.1.1 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.18.0 github.com/stretchr/testify v1.8.4 @@ -26,6 +27,7 @@ require ( github.com/deckarep/golang-set/v2 v2.6.0 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/gorilla/websocket v1.5.1 // indirect + github.com/hashicorp/errwrap v1.0.0 // indirect github.com/holiman/uint256 v1.2.4 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.5.0 // indirect diff --git a/go.sum b/go.sum index 948214d..3450746 100644 --- a/go.sum +++ b/go.sum @@ -45,6 +45,10 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= diff --git a/internal/proxy/healthcheckmanager.go b/internal/proxy/healthcheckmanager.go index cb999c8..5b67158 100644 --- a/internal/proxy/healthcheckmanager.go +++ b/internal/proxy/healthcheckmanager.go @@ -2,10 +2,12 @@ package proxy import ( "context" + "fmt" "log/slog" "strconv" "time" + "github.com/hashicorp/go-multierror" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" ) @@ -83,7 +85,7 @@ func NewHealthCheckManager(config HealthCheckManagerConfig) (*HealthCheckManager } func (h *HealthCheckManager) runLoop(c context.Context) error { - ticker := time.NewTicker(1 * time.Second) + ticker := time.NewTicker(time.Second * 1) defer ticker.Stop() for { @@ -129,12 +131,14 @@ func (h *HealthCheckManager) Start(c context.Context) error { } func (h *HealthCheckManager) Stop(c context.Context) error { + var errs error + for _, hc := range h.hcs { err := hc.Stop(c) if err != nil { - h.logger.Error("could not stop health check manager", "error", err) + errs = multierror.Append(errs, fmt.Errorf("healthcheckManager.Stop error: %w", err)) } } - return nil + return errs }