테스트 코드 돌려놓기
This commit is contained in:
parent
84a1cc5a63
commit
69ab132133
126
bootstrap.go
126
bootstrap.go
|
@ -14,6 +14,7 @@ import (
|
||||||
"amuz.es/src/infra/cpu_ctrl/producer"
|
"amuz.es/src/infra/cpu_ctrl/producer"
|
||||||
"amuz.es/src/infra/cpu_ctrl/consumer"
|
"amuz.es/src/infra/cpu_ctrl/consumer"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func finalCloser() {
|
func finalCloser() {
|
||||||
|
@ -122,77 +123,78 @@ func initProcessor(handler *handler.Handler) func() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//FanoutSpeed := func(sender <-chan producer.FanspeedInfo, receivers ...chan<- producer.FanspeedInfo) {
|
FanoutSpeed := func(sender <-chan producer.FanspeedInfo, receivers ...chan<- producer.FanspeedInfo) {
|
||||||
// defer func() {
|
defer func() {
|
||||||
// for _, receiver := range receivers {
|
for _, receiver := range receivers {
|
||||||
// close(receiver)
|
close(receiver)
|
||||||
// }
|
}
|
||||||
// if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
// handler.NotifyError(err.(error))
|
handler.NotifyError(err.(error))
|
||||||
// }
|
}
|
||||||
// }()
|
}()
|
||||||
// for speed := range sender {
|
for speed := range sender {
|
||||||
// for _, receiver := range receivers {
|
for _, receiver := range receivers {
|
||||||
// select {
|
select {
|
||||||
// case receiver <- speed:
|
case receiver <- speed:
|
||||||
// default:
|
default:
|
||||||
// logger.Warn("Some Fanspeed consumer blocked!")
|
logger.Warn("Some Fanspeed consumer blocked!")
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//FanoutTempeture := func(sender <-chan producer.TempetureInfo, receivers ...chan<- producer.TempetureInfo) {
|
FanoutTempeture := func(sender <-chan producer.TempetureInfo, receivers ...chan<- producer.TempetureInfo) {
|
||||||
// defer func() {
|
defer func() {
|
||||||
//
|
|
||||||
// for _, receiver := range receivers {
|
for _, receiver := range receivers {
|
||||||
// close(receiver)
|
close(receiver)
|
||||||
// }
|
}
|
||||||
// if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
// handler.NotifyError(err.(error))
|
handler.NotifyError(err.(error))
|
||||||
// }
|
}
|
||||||
// }()
|
}()
|
||||||
// for tempeture := range sender {
|
for tempeture := range sender {
|
||||||
// for _, receiver := range receivers {
|
for _, receiver := range receivers {
|
||||||
// select {
|
select {
|
||||||
// case receiver <- tempeture:
|
case receiver <- tempeture:
|
||||||
// default:
|
default:
|
||||||
// logger.Warn("Some Tempeture consumer blocked!")
|
logger.Warn("Some Tempeture consumer blocked!")
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//processorCount := producer.GetProcessorCount()
|
processorCount := producer.GetProcessorCount()
|
||||||
//if processorCount == 0 {
|
if processorCount == 0 {
|
||||||
// panic(errors.New("cpu not found!"))
|
panic(errors.New("cpu not found!"))
|
||||||
//}
|
}
|
||||||
|
|
||||||
osMetricInfoChan := producer.NewOsMetric(
|
osMetricInfoChan := producer.NewOsMetric(
|
||||||
handler,
|
handler,
|
||||||
*SampleInterval,
|
*SampleInterval,
|
||||||
)
|
)
|
||||||
//tempetureInfoChan, fanspeedChan := producer.AggregateProcessorChannel(
|
tempetureInfoChan, fanspeedChan := producer.AggregateProcessorChannel(
|
||||||
// handler,
|
handler,
|
||||||
// *SampleInterval, processorCount,
|
*SampleInterval, processorCount,
|
||||||
// *P, *I, *D,
|
*P, *I, *D,
|
||||||
// *SetPoint,
|
*SetPoint,
|
||||||
//)
|
)
|
||||||
simpleLogger := consumer.NewSampleOSLogger(*SampleInterval, handler)
|
//simpleLogger := consumer.NewSampleOSLogger(*SampleInterval, handler)
|
||||||
//fanController := consumer.NewFanControl(processorCount, *SampleInterval, handler)
|
fanController := consumer.NewFanControl(processorCount, *SampleInterval, handler)
|
||||||
//metricLogger := consumer.NewInfluxMetric((*InfluxHost).String(), processorCount, handler)
|
metricLogger := consumer.NewInfluxMetric((*InfluxHost).String(), processorCount, handler)
|
||||||
|
|
||||||
|
//handler.IncreaseWait()
|
||||||
|
//go simpleLogger.StartControl()
|
||||||
handler.IncreaseWait()
|
handler.IncreaseWait()
|
||||||
go simpleLogger.StartControl()
|
go fanController.StartControl()
|
||||||
//handler.IncreaseWait()
|
handler.IncreaseWait()
|
||||||
//go fanController.StartControl()
|
go metricLogger.StartLogging()
|
||||||
//handler.IncreaseWait()
|
|
||||||
//go metricLogger.StartLogging()
|
|
||||||
|
|
||||||
go FanoutOsMetricInfo(osMetricInfoChan, simpleLogger.Consumer())
|
//go FanoutOsMetricInfo(osMetricInfoChan, simpleLogger.Consumer())
|
||||||
//go FanoutOsMetricInfo(osMetricInfoChan, simpleLogger.Consumer(), metricLogger.OsMetricConsumer())
|
//go FanoutOsMetricInfo(osMetricInfoChan, simpleLogger.Consumer(), metricLogger.OsMetricConsumer())
|
||||||
//go FanoutTempeture(tempetureInfoChan, metricLogger.TempetureConsumer())
|
go FanoutOsMetricInfo(osMetricInfoChan, metricLogger.OsMetricConsumer())
|
||||||
//go FanoutSpeed(fanspeedChan, fanController.Consumer(), metricLogger.FanSpeedConsumer())
|
go FanoutTempeture(tempetureInfoChan, metricLogger.TempetureConsumer())
|
||||||
|
go FanoutSpeed(fanspeedChan, fanController.Consumer(), metricLogger.FanSpeedConsumer())
|
||||||
|
|
||||||
return func() {}
|
return func() {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue