From acc89db356cc437776c394e39822feb99ab53902 Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Tue, 10 Jul 2018 01:34:52 +0900 Subject: [PATCH] =?UTF-8?q?test=20=EC=BD=94=EB=93=9C=EB=A7=8C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=ED=95=B4=EB=B4=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bootstrap.go | 120 +++++++++++++++++++++++++-------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/bootstrap.go b/bootstrap.go index d5bb6f3..7a6b551 100644 --- a/bootstrap.go +++ b/bootstrap.go @@ -14,7 +14,6 @@ import ( "amuz.es/src/infra/cpu_ctrl/producer" "amuz.es/src/infra/cpu_ctrl/consumer" "go.uber.org/zap" - "errors" ) func finalCloser() { @@ -123,76 +122,77 @@ func initProcessor(handler *handler.Handler) func() { } } - FanoutSpeed := func(sender <-chan producer.FanspeedInfo, receivers ...chan<- producer.FanspeedInfo) { - defer func() { - for _, receiver := range receivers { - close(receiver) - } - if err := recover(); err != nil { - handler.NotifyError(err.(error)) - } - }() - for speed := range sender { - for _, receiver := range receivers { - select { - case receiver <- speed: - default: - logger.Warn("Some Fanspeed consumer blocked!") - } - } - } - } - - FanoutTempeture := func(sender <-chan producer.TempetureInfo, receivers ...chan<- producer.TempetureInfo) { - defer func() { - - for _, receiver := range receivers { - close(receiver) - } - if err := recover(); err != nil { - handler.NotifyError(err.(error)) - } - }() - for tempeture := range sender { - for _, receiver := range receivers { - select { - case receiver <- tempeture: - default: - logger.Warn("Some Tempeture consumer blocked!") - } - } - } - } - - processorCount := producer.GetProcessorCount() - if processorCount == 0 { - panic(errors.New("cpu not found!")) - } + //FanoutSpeed := func(sender <-chan producer.FanspeedInfo, receivers ...chan<- producer.FanspeedInfo) { + // defer func() { + // for _, receiver := range receivers { + // close(receiver) + // } + // if err := recover(); err != nil { + // handler.NotifyError(err.(error)) + // } + // }() + // for speed := range sender { + // for _, receiver := range receivers { + // select { + // case receiver <- speed: + // default: + // logger.Warn("Some Fanspeed consumer blocked!") + // } + // } + // } + //} + // + //FanoutTempeture := func(sender <-chan producer.TempetureInfo, receivers ...chan<- producer.TempetureInfo) { + // defer func() { + // + // for _, receiver := range receivers { + // close(receiver) + // } + // if err := recover(); err != nil { + // handler.NotifyError(err.(error)) + // } + // }() + // for tempeture := range sender { + // for _, receiver := range receivers { + // select { + // case receiver <- tempeture: + // default: + // logger.Warn("Some Tempeture consumer blocked!") + // } + // } + // } + //} + // + //processorCount := producer.GetProcessorCount() + //if processorCount == 0 { + // panic(errors.New("cpu not found!")) + //} osMetricInfoChan := producer.NewOsMetric( handler, *SampleInterval, ) - tempetureInfoChan, fanspeedChan := producer.AggregateProcessorChannel( - handler, - *SampleInterval, processorCount, - *P, *I, *D, - *SetPoint, - ) + //tempetureInfoChan, fanspeedChan := producer.AggregateProcessorChannel( + // handler, + // *SampleInterval, processorCount, + // *P, *I, *D, + // *SetPoint, + //) simpleLogger := consumer.NewSampleOSLogger(*SampleInterval, handler) - fanController := consumer.NewFanControl(processorCount, *SampleInterval, handler) - metricLogger := consumer.NewInfluxMetric((*InfluxHost).String(), processorCount, handler) + //fanController := consumer.NewFanControl(processorCount, *SampleInterval, handler) + //metricLogger := consumer.NewInfluxMetric((*InfluxHost).String(), processorCount, handler) handler.IncreaseWait() go simpleLogger.StartControl() - handler.IncreaseWait() - go fanController.StartControl() - handler.IncreaseWait() - go metricLogger.StartLogging() + //handler.IncreaseWait() + //go fanController.StartControl() + //handler.IncreaseWait() + //go metricLogger.StartLogging() go FanoutOsMetricInfo(osMetricInfoChan, simpleLogger.Consumer()) - go FanoutTempeture(tempetureInfoChan, metricLogger.TempetureConsumer()) - go FanoutSpeed(fanspeedChan, fanController.Consumer(), metricLogger.FanSpeedConsumer()) + //go FanoutOsMetricInfo(osMetricInfoChan, simpleLogger.Consumer(), metricLogger.OsMetricConsumer()) + //go FanoutTempeture(tempetureInfoChan, metricLogger.TempetureConsumer()) + //go FanoutSpeed(fanspeedChan, fanController.Consumer(), metricLogger.FanSpeedConsumer()) return func() {} }