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) } }