예제 #1
0
// Fetch correct output and iterate over received messages, checking against
// message hostname and delivering to the output if hostname is in our config.
func (f *HostFilter) Run(runner pipeline.FilterRunner, helper pipeline.PluginHelper) (
	err error) {

	var (
		hostname string
		output   pipeline.OutputRunner
		ok       bool
	)

	if output, ok = helper.Output(f.output); !ok {
		return fmt.Errorf("No output: %s", output)
	}
	for plc := range runner.InChan() {
		hostname = plc.Pack.Message.GetHostname()
		if f.hosts[hostname] {
			output.Deliver(plc.Pack)
		} else {
			plc.Pack.Recycle()
		}
	}
	return
}