-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathdevnull.go
43 lines (35 loc) · 917 Bytes
/
devnull.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package workers
import (
"github.com/dmachard/go-dnscollector/pkgconfig"
"github.com/dmachard/go-logger"
)
type DevNull struct {
*GenericWorker
}
func NewDevNull(config *pkgconfig.Config, console *logger.Logger, name string) *DevNull {
bufSize := config.Global.Worker.ChannelBufferSize
if config.Loggers.DevNull.ChannelBufferSize > 0 {
bufSize = config.Loggers.DevNull.ChannelBufferSize
}
s := &DevNull{GenericWorker: NewGenericWorker(config, console, name, "devnull", bufSize, pkgconfig.DefaultMonitor)}
s.ReadConfig()
return s
}
func (w *DevNull) StartCollect() {
w.LogInfo("starting data collection")
defer w.CollectDone()
// loop to process incoming messages
for {
select {
case <-w.OnStop():
return
case _, opened := <-w.GetInputChannel():
if !opened {
w.LogInfo("run: input channel closed!")
return
}
// count global messages
w.CountIngressTraffic()
}
}
}