diff --git a/main.go b/main.go index e844224..b4acadb 100644 --- a/main.go +++ b/main.go @@ -10,10 +10,10 @@ import ( "net/http" ) -type telemetry struct { - slug string `json:"slug"` - eventType string `json:"type"` - qualityChangeUp bool `json:"isUp"` +type Telemetry struct { + Slug string `json:"slug"` + EventType string `json:"type"` + QualityChangeUp bool `json:"isUp"` } type metrics struct { @@ -24,9 +24,9 @@ type metrics struct { } const ( - type_buffering = "buffering" - type_recovery = "recovery" - type_quality_switch = "quality_switch" + typeBuffering = "buffering" + typeRecovery = "recovery" + typeQualitySwitch = "quality_switch" ) func main() { @@ -60,22 +60,22 @@ func main() { func telemetryHandler(m metrics) echo.HandlerFunc { return func(c echo.Context) error { - t := new([]telemetry) + t := new([]Telemetry) if err := c.Bind(t); err != nil { return c.String(http.StatusBadRequest, "bad request") } for _, v := range *t { - switch v.eventType { - case type_buffering: - m.buffering.WithLabelValues(v.slug).Inc() - case type_recovery: - m.recovery.WithLabelValues(v.slug).Inc() - case type_quality_switch: - if v.qualityChangeUp { - m.qualityUp.WithLabelValues(v.slug).Inc() + switch v.EventType { + case typeBuffering: + m.buffering.WithLabelValues(v.Slug).Inc() + case typeRecovery: + m.recovery.WithLabelValues(v.Slug).Inc() + case typeQualitySwitch: + if v.QualityChangeUp { + m.qualityUp.WithLabelValues(v.Slug).Inc() } else { - m.qualityDown.WithLabelValues(v.slug).Inc() + m.qualityDown.WithLabelValues(v.Slug).Inc() } } } diff --git a/package.nix b/package.nix index e3bf5d9..5540945 100644 --- a/package.nix +++ b/package.nix @@ -5,7 +5,7 @@ let deps = [ ]; nativeDeps = [ ]; in -pkgs.buildGo119Module { +pkgs.buildGo121Module { pname = "voc-telemetry"; inherit version; src = ./.;