This repository was archived by the owner on Mar 27, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed
Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ const (
4444)
4545
4646var (
47- version = "x.x.x "
47+ version = "0.0.0-dev "
4848 debugMqtt = false
4949)
5050
Original file line number Diff line number Diff line change @@ -31,10 +31,11 @@ import (
3131
3232// Status contains info about the sketches running on the device
3333type Status struct {
34- id string
35- mqttClient mqtt.Client
36- Sketches map [string ]* SketchStatus `json:"sketches"`
37- messagesSent int
34+ id string
35+ mqttClient mqtt.Client
36+ Sketches map [string ]* SketchStatus `json:"sketches"`
37+ messagesSent int
38+ firstMessageAt time.Time
3839}
3940
4041// SketchBinding represents a pair (SketchName,SketchId)
@@ -121,7 +122,18 @@ func (s *Status) Raw(topic, msg string) {
121122 if s .mqttClient == nil {
122123 return
123124 }
125+
126+ if s .messagesSent < 10 {
127+ // first 10 messages are virtually free
128+ s .firstMessageAt = time .Now ()
129+ }
130+
124131 if s .messagesSent > 1000 {
132+ // if started more than one day ago, reset the counter
133+ if time .Since (s .firstMessageAt ) > 24 * time .Hour {
134+ s .messagesSent = 0
135+ }
136+
125137 fmt .Println ("rate limiting: " + strconv .Itoa (s .messagesSent ))
126138 introducedDelay := time .Duration (s .messagesSent / 1000 ) * time .Second
127139 if introducedDelay > 20 * time .Second {
Original file line number Diff line number Diff line change @@ -232,9 +232,19 @@ func (u *Updater) update() error {
232232 return err
233233 }
234234
235+ // this is the version publically available (GA)
235236 v1 , _ := semver .Make (u .Info .Version )
237+ // this is the version of the actual binary at start
236238 v2 , _ := semver .Make (u .CurrentVersion )
237239
240+ if len (v2 .Pre ) > 0 {
241+ log .Println ("Prerelease versions:" )
242+ for _ , pre := range v2 .Pre {
243+ if pre .String () == "dev" {
244+ return errors .New ("dev version" )
245+ }
246+ }
247+ }
238248 if v1 .Compare (v2 ) <= 0 {
239249 return errors .New ("already at latest version" )
240250 }
You can’t perform that action at this time.
0 commit comments