chore: remove empty param keys like for util.Flusher from message pipe (#6448)
Some checks failed
Some checks failed
This commit is contained in:
parent
0efce70b8b
commit
742b2bea80
2 changed files with 9 additions and 13 deletions
|
|
@ -37,7 +37,8 @@ var (
|
|||
log = util.NewLogger("main")
|
||||
cfgFile string
|
||||
|
||||
ignoreErrors = []string{"warn", "error"} // don't add to cache
|
||||
ignoreEmpty = "" // ignore empty keys
|
||||
ignoreErrors = []string{"warn", "error"} // ignore errors
|
||||
ignoreMqtt = []string{"auth", "releaseNotes"} // excessive size may crash certain brokers
|
||||
)
|
||||
|
||||
|
|
@ -152,7 +153,7 @@ func runRoot(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
|
||||
// publish to UI
|
||||
go socketHub.Run(tee.Attach(), cache)
|
||||
go socketHub.Run(pipe.NewDropper(ignoreEmpty).Pipe(tee.Attach()), cache)
|
||||
|
||||
// setup values channel
|
||||
valueChan := make(chan util.Param)
|
||||
|
|
@ -192,13 +193,13 @@ func runRoot(cmd *cobra.Command, args []string) {
|
|||
|
||||
// setup database
|
||||
if err == nil && conf.Influx.URL != "" {
|
||||
configureInflux(conf.Influx, site, tee.Attach())
|
||||
configureInflux(conf.Influx, site, pipe.NewDropper(append(ignoreErrors, ignoreEmpty)...).Pipe(tee.Attach()))
|
||||
}
|
||||
|
||||
// setup mqtt publisher
|
||||
if err == nil && conf.Mqtt.Broker != "" {
|
||||
publisher := server.NewMQTT(strings.Trim(conf.Mqtt.Topic, "/"))
|
||||
go publisher.Run(site, pipe.NewDropper(ignoreMqtt...).Pipe(tee.Attach()))
|
||||
go publisher.Run(site, pipe.NewDropper(append(ignoreMqtt, ignoreEmpty)...).Pipe(tee.Attach()))
|
||||
}
|
||||
|
||||
// announce on mDNS
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/benbjohnson/clock"
|
||||
"github.com/evcc-io/evcc/util"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
// Piper is the interface that data flow plugins must implement
|
||||
|
|
@ -113,17 +114,11 @@ func NewDropper(filter ...string) Piper {
|
|||
|
||||
func (l *Dropper) pipe(in <-chan util.Param, out chan<- util.Param) {
|
||||
for p := range in {
|
||||
var remove bool
|
||||
for _, filtered := range l.filter {
|
||||
if p.Key == filtered {
|
||||
remove = true
|
||||
break
|
||||
}
|
||||
if slices.Contains(l.filter, p.Key) {
|
||||
continue
|
||||
}
|
||||
|
||||
if !remove {
|
||||
out <- p
|
||||
}
|
||||
out <- p
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue