1
0
Fork 0

체널 용량 조정

This commit is contained in:
Sangbum Kim 2017-09-24 20:17:56 +09:00
parent b297c3d6ed
commit aab5631ca7
1 changed files with 13 additions and 13 deletions

View File

@ -37,8 +37,8 @@ func NewInfluxMetric(host string, processorCount int, handler util.Handler) Infl
host: host, host: host,
processorCount: processorCount, processorCount: processorCount,
handler: handler, handler: handler,
fanSpeedConsumer: make(chan processor.FanspeedInfo, 1), fanSpeedConsumer: make(chan processor.FanspeedInfo, processorCount),
tempetureConsumer: make(chan processor.TempetureInfo, 1), tempetureConsumer: make(chan processor.TempetureInfo, processorCount),
} }
} }
@ -86,18 +86,18 @@ func (m *influxMetric) StartLogging() {
panic(err) panic(err)
} }
ticker := time.Tick(time.Second) ticker := time.Tick(time.Second)
dataList := make([]data,m.processorCount) metricData := make([]data, m.processorCount)
for { for {
select { select {
case <-ticker: case <-ticker:
sendData := make([]data, m.processorCount) sendData := make([]data, m.processorCount)
copy(sendData,dataList) copy(sendData, metricData)
go m.sendPoint(influxDbConn, batchPoint, sendData) go m.sendPoint(influxDbConn, batchPoint, sendData)
case changedSpeed := <-m.fanSpeedConsumer: case changedSpeed := <-m.fanSpeedConsumer:
dataList[changedSpeed.Id].FanSpeed =changedSpeed.FanSpeed metricData[changedSpeed.Id].FanSpeed = changedSpeed.FanSpeed
case changedTempeture := <-m.tempetureConsumer: case changedTempeture := <-m.tempetureConsumer:
dataList[changedTempeture.Id].Tempeture =changedTempeture.Tempeture metricData[changedTempeture.Id].Tempeture = changedTempeture.Tempeture
case <-m.handler.Done(): case <-m.handler.Done():
return return
} }