Class: RFlow::Components::Replicate

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

Overview

A component that replicates all inbound messages onto a single out port in order to easily support a many-to-many connection pattern (connect all the ins to this component and all the outs to this component instead of all of the ins to all of the outs).

Emits Messages of whatever type was sent in. Any messages with problems being sent to #out will be sent to #errored instead.

Instance Attribute Summary collapse

Attributes inherited from RFlow::Component

#name, #ports, #shard, #uuid, #worker

Instance Method Summary collapse

Methods inherited from RFlow::Component

build, #cleanup!, #configure!, #initialize, input_port, #input_ports, output_port, #output_ports, #run!, #shutdown!, #to_s

Constructor Details

This class inherits a constructor from RFlow::Component

Instance Attribute Details

#erroredComponent::OutputPort (readonly)

Outputs Messagess that could not be sent to #errored.



23
# File 'lib/rflow/components/replicate.rb', line 23

output_port :errored

#inComponent::InputPort (readonly)

Receives Messages.



15
# File 'lib/rflow/components/replicate.rb', line 15

input_port :in

#outComponent::OutputPort (readonly)

Outputs Messages.



19
# File 'lib/rflow/components/replicate.rb', line 19

output_port :out

Instance Method Details

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

This method returns an undefined value.

RFlow-called method on message arrival.



27
28
29
30
31
32
33
34
35
36
# File 'lib/rflow/components/replicate.rb', line 27

def process_message(input_port, input_port_key, connection, message)
  out.each do |connections|
    begin
      connections.send_message message
    rescue Exception => e
      RFlow.logger.debug "#{self.class} Message caused exception: #{e.class}: #{e.message}: #{e.backtrace}"
      errored.send_message message
    end
  end
end