Sha256: 189037369b41f02447ed9ec336faee52a3ad35378dfffd117c7eddb225464347

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

class RFlow
  # Components.
  module Components
    # 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 {RFlow::Message}s of whatever type was sent in. Any messages with
    # problems being sent to {out} will be sent to {errored} instead.
    class Replicate < Component
      # @!attribute [r] in
      #   Receives {RFlow::Message}s.
      #   @return [Component::InputPort]
      input_port :in
      # @!attribute [r] out
      #   Outputs {RFlow::Message}s.
      #   @return [Component::OutputPort]
      output_port :out
      # @!attribute [r] errored
      #   Outputs {RFlow::Messages}s that could not be sent to {errored}.
      #   @return [Component::OutputPort]
      output_port :errored

      # RFlow-called method on message arrival.
      # @return [void]
      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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rflow-1.3.2 lib/rflow/components/replicate.rb
rflow-1.3.1 lib/rflow/components/replicate.rb