Skip to content

Commit

Permalink
fix: actually separate collector by device for multi-device stations
Browse files Browse the repository at this point in the history
  • Loading branch information
tris committed Jul 24, 2023
1 parent e9a928b commit b42749d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ func (we *WeatherExporter) ScrapeHandler(w http.ResponseWriter, r *http.Request)
client = weatherflow.NewClient(apiToken, nil, prefixedLogger(apiToken, log.Printf))
we.clients[apiToken] = client
client.Start(func(msg weatherflow.Message) {
deviceID, ok := msg.GetDeviceID()
if !ok {
return
}
collector, ok := collectorsForToken[deviceID]
if !ok {
return
}
collector.update(msg, apiToken)
})
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
github.com/prometheus/client_golang v1.15.1
github.com/tris/weatherflow v0.3.0
github.com/tris/weatherflow v0.3.1
)

require (
Expand Down

0 comments on commit b42749d

Please sign in to comment.