remove multi_filter

This commit is contained in:
Joao Duarte 2015-04-13 16:00:17 +01:00 committed by Colin Surprenant
parent d8f23189c1
commit 4d6f941361
3 changed files with 2 additions and 34 deletions

View file

@ -230,7 +230,7 @@ module LogStash; module Config; module AST
return "start_input(#{variable_name})"
when "filter"
return <<-CODE
events = #{variable_name}.multi_filter(events)
#{variable_name}.filter(event) {|new_event| events << new_event }
CODE
when "output"
return "#{variable_name}.handle(event)\n"

View file

@ -146,24 +146,6 @@ class LogStash::Filters::Base < LogStash::Plugin
raise "#{self.class}#filter must be overidden"
end # def filter
# in 1.5.0 multi_filter is meant to be used in the generated filter function in LogStash::Config::AST::Plugin only
# and is temporary until we refactor the filter method interface to accept events list and return events list,
# just list in multi_filter see https://github.com/elastic/logstash/issues/2872.
# refactoring the filter method will mean updating all plugins which we want to avoid doing for 1.5.0.
#
# @param events [Array<LogStash::Event] list of events to filter
# @return [Array<LogStash::Event] filtered events and any new events generated by the filter
public
def multi_filter(events)
result = []
events.each do |event|
result << event
filter(event){|new_event| result << new_event}
end
result
end
public
def execute(event, &block)
filter(event, &block)

View file

@ -24,24 +24,10 @@ describe LogStash::Filters::Base do
end
it "should provide class public API" do
[:register, :filter, :multi_filter, :execute, :threadsafe?, :filter_matched, :filter?, :teardown].each do |method|
[:register, :filter, :execute, :threadsafe?, :filter_matched, :filter?, :teardown].each do |method|
expect(subject).to respond_to(method)
end
end
it "should multi_filter without new events" do
allow(subject).to receive(:filter) do |event, &block|
nil
end
expect(subject.multi_filter([:foo])).to eq([:foo])
end
it "should multi_filter with new events" do
allow(subject).to receive(:filter) do |event, &block|
block.call(:bar)
end
expect(subject.multi_filter([:foo])).to eq([:foo, :bar])
end
end
describe LogStash::Filters::NOOP do