mirror of
https://github.com/netsampler/goflow2.git
synced 2024-05-06 15:54:52 +00:00
* netflow: Add observation domain and point to message The ObservationDomainID and ObservationPointID are two IPFIX fields that identify the entity that is capturing flows and can be used to enrich the context around a specific sample. Parse these fields from the sample and add them to the FlowMessage. Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Co-authored-by: Adrian Moreno <amorenoz@redhat.com>
34 lines
560 B
Go
34 lines
560 B
Go
package utils
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
// ErrAlreadyStarted error happens when you try to start twice a flow routine
|
|
var ErrAlreadyStarted = errors.New("the routine is already started")
|
|
|
|
// stopper mechanism, common for all the flow routines
|
|
type stopper struct {
|
|
stopCh chan struct{}
|
|
}
|
|
|
|
func (s *stopper) start() error {
|
|
if s.stopCh != nil {
|
|
return ErrAlreadyStarted
|
|
}
|
|
s.stopCh = make(chan struct{})
|
|
return nil
|
|
}
|
|
|
|
func (s *stopper) Shutdown() {
|
|
if s.stopCh != nil {
|
|
select {
|
|
case <-s.stopCh:
|
|
default:
|
|
close(s.stopCh)
|
|
}
|
|
|
|
s.stopCh = nil
|
|
}
|
|
}
|