From 2c0f88b6f4ece1f8e2ca597cae0c51bd067b6cda Mon Sep 17 00:00:00 2001 From: sqshq Date: Sat, 2 Feb 2019 23:11:26 -0500 Subject: [PATCH] minor refactoring --- data/poller.go | 12 ++++++------ main.go | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data/poller.go b/data/poller.go index 05025a0..bb03caf 100644 --- a/data/poller.go +++ b/data/poller.go @@ -4,29 +4,29 @@ import ( "time" ) -type Poller struct { +type Sampler struct { consumer Consumer item Item } -func NewPoller(consumer Consumer, item Item, rateMs int) Poller { +func NewSampler(consumer Consumer, item Item, rateMs int) Sampler { ticker := time.NewTicker(time.Duration(rateMs * int(time.Millisecond))) - poller := Poller{consumer, item} + sampler := Sampler{consumer, item} go func() { for { select { case <-ticker.C: - poller.poll() + sampler.sample() } } }() - return poller + return sampler } -func (self *Poller) poll() { +func (self *Sampler) sample() { value, err := self.item.nextValue() diff --git a/main.go b/main.go index 0bc4f26..c5a90b1 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,7 @@ func main() { layout.AddComponent(chart, chartConfig.Position, chartConfig.Size, widgets.TypeRunChart) for _, item := range chartConfig.Items { - data.NewPoller(chart, item, chartConfig.RefreshRateMs) + data.NewSampler(chart, item, chartConfig.RefreshRateMs) } }