aboutsummaryrefslogtreecommitdiffstats
path: root/internal/weather/types.go
diff options
context:
space:
mode:
authorPetri Hienonen <petri.hienonen@gmail.com>2026-01-04 11:52:47 +0200
committerPetri Hienonen <petri.hienonen@gmail.com>2026-01-04 11:52:47 +0200
commit59491201976316a30ffc475dd99b0af02b5e997d (patch)
treeecf395594d5d289d855eba16f786e0fb66c1d814 /internal/weather/types.go
parent4e0ca0509c6b314eea8a7b2df6d093f5d9b7e70f (diff)
downloadpub-59491201976316a30ffc475dd99b0af02b5e997d.tar.zst
Both publisher and subscriber
Diffstat (limited to 'internal/weather/types.go')
-rw-r--r--internal/weather/types.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/internal/weather/types.go b/internal/weather/types.go
new file mode 100644
index 0000000..5563bfa
--- /dev/null
+++ b/internal/weather/types.go
@@ -0,0 +1,44 @@
+package weather
+
+import (
+ "encoding/json"
+ "math"
+ "time"
+)
+
+// Observation represents a weather observation from a station
+type Observation struct {
+ Station int `json:"station"`
+ Parameter string `json:"parameter"`
+ Time time.Time `json:"time"`
+ Value *float64 `json:"value,omitempty"`
+}
+
+// ForecastValue represents a weather forecast value
+type ForecastValue struct {
+ Location struct {
+ Lat float64 `json:"lat"`
+ Lon float64 `json:"lon"`
+ } `json:"location"`
+ Model string `json:"model"`
+ RunTime time.Time `json:"run_time"`
+ ForecastTime time.Time `json:"forecast_time"`
+ Parameter string `json:"parameter"`
+ Value *float64 `json:"value,omitempty"`
+}
+
+// JSONFloat64 handles NaN values properly in JSON
+type JSONFloat64 float64
+
+func (f JSONFloat64) MarshalJSON() ([]byte, error) {
+ if math.IsNaN(float64(f)) {
+ return []byte("null"), nil
+ }
+ return json.Marshal(float64(f))
+}
+
+// TopicStats tracks message statistics for subscribers
+type TopicStats struct {
+ MessagesReceived map[string]int
+ LastMessageTime map[string]time.Time
+}