Don't commit errors and warnings to cache

This commit is contained in:
andig 2020-07-31 07:37:49 +02:00
parent ff880489e6
commit 2d187750fb
4 changed files with 43 additions and 7 deletions

View file

@ -8,14 +8,16 @@ import (
"github.com/andig/evcc/server"
"github.com/andig/evcc/server/updater"
"github.com/andig/evcc/util"
"github.com/andig/evcc/util/pipe"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var (
log = util.NewLogger("main")
cfgFile string
ignoreParams = []string{"warn", "error", "fatal"} // don't add to cache
log = util.NewLogger("main")
cfgFile string
)
// rootCmd represents the base command when called without any subcommands
@ -134,7 +136,7 @@ func run(cmd *cobra.Command, args []string) {
// value cache
cache := util.NewCache()
go cache.Run(tee.Attach())
go cache.Run(pipe.NewDropper(ignoreParams...).Pipe(tee.Attach()))
// setup loadpoints
site := loadConfig(conf)

View file

@ -11,6 +11,7 @@ import (
"github.com/andig/evcc/push"
"github.com/andig/evcc/server"
"github.com/andig/evcc/util"
"github.com/andig/evcc/util/pipe"
"github.com/spf13/viper"
)
@ -30,11 +31,11 @@ func configureDatabase(conf server.InfluxConfig, loadPoints []*core.LoadPoint, i
)
// eliminate duplicate values
dedupe := server.NewDeduplicator(30*time.Minute, "socCharge")
dedupe := pipe.NewDeduplicator(30*time.Minute, "socCharge")
in = dedupe.Pipe(in)
// reduce number of values written to influx
limiter := server.NewLimiter(5 * time.Second)
limiter := pipe.NewLimiter(5 * time.Second)
in = limiter.Pipe(in)
go influx.Run(loadPoints, in)