Allow Flow Routines to be cancellable (#40)

* Allow Flow Routines to be cancellable
This commit is contained in:
Mario Macias
2021-11-01 00:42:07 +01:00
committed by GitHub
parent 92043a6233
commit d1e1ace318
7 changed files with 259 additions and 37 deletions

View File

@@ -14,6 +14,8 @@ import (
)
type StateSFlow struct {
stopper
Format format.FormatInterface
Transport transport.TransportInterface
Logger Logger
@@ -153,6 +155,9 @@ func (s *StateSFlow) initConfig() {
}
func (s *StateSFlow) FlowRoutine(workers int, addr string, port int, reuseport bool) error {
if err := s.start(); err != nil {
return err
}
s.initConfig()
return UDPRoutine("sFlow", s.DecodeFlow, workers, addr, port, reuseport, s.Logger)
return UDPStoppableRoutine(s.stopCh, "sFlow", s.DecodeFlow, workers, addr, port, reuseport, s.Logger)
}