Class: RFlow::Components::RubyProcFilter

Inherits:
RFlow::Component show all
Defined in:
lib/rflow/components/ruby_proc_filter.rb

Instance Attribute Summary

Attributes inherited from RFlow::Component

#name, #ports, #uuid, #worker

Instance Method Summary collapse

Methods inherited from RFlow::Component

build, #cleanup!, #configure_input_port!, #configure_output_port!, #connect_inputs!, #connect_outputs!, define_port, defined_input_ports, defined_output_ports, inherited, #initialize, input_port, #input_ports, output_port, #output_ports, #run!, #shard, #shutdown!, #to_s

Constructor Details

This class inherits a constructor from RFlow::Component

Instance Method Details

#configure!(config) ⇒ Object



9
10
11
# File 'lib/rflow/components/ruby_proc_filter.rb', line 9

def configure!(config)
  @filter_proc = eval("lambda {|message| #{config['filter_proc_string']} }")
end

#process_message(input_port, input_port_key, connection, message) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rflow/components/ruby_proc_filter.rb', line 13

def process_message(input_port, input_port_key, connection, message)
  begin
    if @filter_proc.call(message)
      filtered.send_message message
    else
      dropped.send_message message
    end
  rescue Exception => e
    RFlow.logger.debug "#{self.class} Message caused exception: #{e.class}: #{e.message}: #{e.backtrace}"
    errored.send_message message
  end
end