diff --git a/meters/device.go b/meters/device.go index 9a3082ba..64f24610 100644 --- a/meters/device.go +++ b/meters/device.go @@ -21,12 +21,12 @@ type DeviceDescriptor struct { // Device is a modbus device that can be described, probed and queried type Device interface { - // Initialize prepares the device for usage. Any setup or initilization should be done here. + // Initialize prepares the device for usage. Any setup or initialization should be done here. // It requires that the client has the correct device id applied. Initialize(client modbus.Client) error // Descriptor returns the device descriptor. Since this method does not have - // bus access the descriptor should be preared during initilization. + // bus access the descriptor should be prepared during initialization. Descriptor() DeviceDescriptor // Probe tests if a basic register, typically VoltageL1, can be read. diff --git a/server/queryengine.go b/server/queryengine.go index cff4bd66..394248a4 100644 --- a/server/queryengine.go +++ b/server/queryengine.go @@ -85,6 +85,9 @@ func (q *QueryEngine) Run( for _, h := range q.handlers { wg.Add(1) go func(h *Handler) { + ticker := time.NewTicker(rate) + defer ticker.Stop() + for { // run handlers h.Run(ctx, control, results) @@ -95,7 +98,7 @@ func (q *QueryEngine) Run( // abort if context is cancelled wg.Done() return - case <-time.After(rate): + case <-ticker.C: } } }(h)