|
|
@ -35,7 +35,7 @@ type monitor struct { |
|
|
|
droppedCount int |
|
|
|
droppedCount int |
|
|
|
|
|
|
|
|
|
|
|
// doneCh coordinates the shutdown of logCh
|
|
|
|
// doneCh coordinates the shutdown of logCh
|
|
|
|
doneCh chan struct{} |
|
|
|
doneCh chan bool |
|
|
|
|
|
|
|
|
|
|
|
// Defaults to 512.
|
|
|
|
// Defaults to 512.
|
|
|
|
bufSize int |
|
|
|
bufSize int |
|
|
@ -58,7 +58,7 @@ func New(cfg Config) Monitor { |
|
|
|
sw := &monitor{ |
|
|
|
sw := &monitor{ |
|
|
|
logger: cfg.Logger, |
|
|
|
logger: cfg.Logger, |
|
|
|
logCh: make(chan []byte, bufSize), |
|
|
|
logCh: make(chan []byte, bufSize), |
|
|
|
doneCh: make(chan struct{}, 1), |
|
|
|
doneCh: make(chan bool, 1), |
|
|
|
bufSize: bufSize, |
|
|
|
bufSize: bufSize, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -72,7 +72,11 @@ func New(cfg Config) Monitor { |
|
|
|
// Stop deregisters the sink and stops the monitoring process
|
|
|
|
// Stop deregisters the sink and stops the monitoring process
|
|
|
|
func (d *monitor) Stop() int { |
|
|
|
func (d *monitor) Stop() int { |
|
|
|
d.logger.DeregisterSink(d.sink) |
|
|
|
d.logger.DeregisterSink(d.sink) |
|
|
|
close(d.doneCh) |
|
|
|
select { |
|
|
|
|
|
|
|
case d.doneCh <- true: |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return d.droppedCount |
|
|
|
return d.droppedCount |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|