체널 용량 조정
This commit is contained in:
parent
b297c3d6ed
commit
aab5631ca7
|
@ -37,8 +37,8 @@ func NewInfluxMetric(host string, processorCount int, handler util.Handler) Infl
|
|||
host: host,
|
||||
processorCount: processorCount,
|
||||
handler: handler,
|
||||
fanSpeedConsumer: make(chan processor.FanspeedInfo, 1),
|
||||
tempetureConsumer: make(chan processor.TempetureInfo, 1),
|
||||
fanSpeedConsumer: make(chan processor.FanspeedInfo, processorCount),
|
||||
tempetureConsumer: make(chan processor.TempetureInfo, processorCount),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,18 +86,18 @@ func (m *influxMetric) StartLogging() {
|
|||
panic(err)
|
||||
}
|
||||
ticker := time.Tick(time.Second)
|
||||
dataList := make([]data,m.processorCount)
|
||||
metricData := make([]data, m.processorCount)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ticker:
|
||||
sendData := make([]data, m.processorCount)
|
||||
copy(sendData,dataList)
|
||||
copy(sendData, metricData)
|
||||
go m.sendPoint(influxDbConn, batchPoint, sendData)
|
||||
case changedSpeed := <-m.fanSpeedConsumer:
|
||||
dataList[changedSpeed.Id].FanSpeed =changedSpeed.FanSpeed
|
||||
metricData[changedSpeed.Id].FanSpeed = changedSpeed.FanSpeed
|
||||
case changedTempeture := <-m.tempetureConsumer:
|
||||
dataList[changedTempeture.Id].Tempeture =changedTempeture.Tempeture
|
||||
metricData[changedTempeture.Id].Tempeture = changedTempeture.Tempeture
|
||||
case <-m.handler.Done():
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue