func (this *EsFilter) Run(r engine.FilterRunner, h engine.PluginHelper) error { var ( globals = engine.Globals() pack *engine.PipelinePack ok = true count = 0 inChan = r.InChan() ) LOOP: for ok { select { case pack, ok = <-inChan: if !ok { break LOOP } if globals.Debug { globals.Println(*pack) } if this.handlePack(pack, h.Project(pack.Project)) { count += 1 r.Inject(pack) } else { pack.Recycle() } } } globals.Printf("[%s]Total filtered: %d", r.Name(), count) return nil }
func (this *EsBufferFilter) Run(r engine.FilterRunner, h engine.PluginHelper) error { var ( pack *engine.PipelinePack ok = true globals = engine.Globals() inChan = r.InChan() ) for _, worker := range this.wokers { go worker.run(r, h) } LOOP: for ok { select { case pack, ok = <-inChan: if !ok { break LOOP } if globals.Debug { globals.Println(*pack) } this.handlePack(pack) pack.Recycle() } } total := 0 for _, worker := range this.wokers { total += worker.summary.N worker.flush(r, h) } // all workers will get notified and stop running close(this.stopChan) globals.Printf("[%s]Total filtered: %d", r.Name(), total) return nil }