From a2d7f5e7202c467f5d4d8eff415dec10ffc16e6a Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Tue, 26 Sep 2017 07:59:13 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A9=94=EB=AA=A8=EB=A6=AC=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=EC=A4=84=EC=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- consumer/influx_stat.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/consumer/influx_stat.go b/consumer/influx_stat.go index 5d0bc5f..8bccca0 100644 --- a/consumer/influx_stat.go +++ b/consumer/influx_stat.go @@ -86,18 +86,17 @@ func (m *influxMetric) StartLogging() { panic(err) } ticker := time.Tick(time.Second) - metricData := make([]data, m.processorCount) + pastMetricData, newMetricData := make([]data, m.processorCount), make([]data, m.processorCount) for { select { case <-ticker: - sendData := make([]data, m.processorCount) - copy(sendData, metricData) - m.sendPoint(influxDbConn, batchPoint, sendData) + copy(pastMetricData, newMetricData) + go m.sendPoint(influxDbConn, batchPoint, pastMetricData) case changedSpeed := <-m.fanSpeedConsumer: - metricData[changedSpeed.Id].FanSpeed = changedSpeed.FanSpeed + newMetricData[changedSpeed.Id].FanSpeed = changedSpeed.FanSpeed case changedTempeture := <-m.tempetureConsumer: - metricData[changedTempeture.Id].Tempeture = changedTempeture.Tempeture + newMetricData[changedTempeture.Id].Tempeture = changedTempeture.Tempeture case <-m.handler.Done(): return }