Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

fix: missing error handling #184

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
10 changes: 7 additions & 3 deletions internal/proxy/healthcheckmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Loading