Skip to content

Commit

Permalink
Limit retries for meter reading
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Apr 19, 2020
1 parent e50cac2 commit 116cb0f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions core/loadpoint.go
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/andig/evcc/api"
"github.com/andig/evcc/core/wrapper"
"github.com/andig/evcc/push"
"github.com/pkg/errors"

evbus "github.com/asaskevich/EventBus"
"github.com/avast/retry-go"
Expand Down Expand Up @@ -437,19 +438,14 @@ func (lp *LoadPoint) updateMeter(name string, meter api.Meter, power *float64) e

// updateMeter updates and publishes single meter
func (lp *LoadPoint) updateMeters() (err error) {
// var wg sync.WaitGroup
// var mux sync.Mutex
retry := func(s string, m api.Meter, f *float64) {
e := retry.Do(func() error {
return lp.updateMeter(s, m, f)
})
}, retry.Attempts(3))
if e != nil {
err = errors.Wrapf(e, "updating %s meter", s)
log.ERROR.Printf("%s %v", lp.Name, err)
// mux.Lock()
err = e
// mux.Unlock()
}
// wg.Done()
}

// read PV meter before charge meter
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -26,7 +26,7 @@ require (
github.com/mitchellh/mapstructure v1.2.2
github.com/mjibson/esc v0.2.0
github.com/pelletier/go-toml v1.7.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/errors v0.9.1
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.0.0
Expand Down

0 comments on commit 116cb0f

Please sign in to comment.