class RFlow::Connection

Represents an RFlow connection from one component to another.

Attributes

config[RW]

The reference to the connection's configuration. @return [Configuration::Connection]

name[RW]

The connection's name. @return [String]

options[RW]

The connection's options Hash. @return [Hash]

recv_callback[RW]
uuid[RW]

The connection's UUID. @return [String]

Public Class Methods

build(config) click to toggle source

Build an appropriate subclass of {Connection} based on the configuration. @return [Connection]

# File lib/rflow/connection.rb, line 9
def build(config)
  case config.type
  when 'RFlow::Configuration::ZMQConnection'
    RFlow::Connections::ZMQConnection.new(config)
  when 'RFlow::Configuration::BrokeredZMQConnection'
    RFlow::Connections::BrokeredZMQConnection.new(config)
  else
    raise ArgumentError, 'Only ZMQConnections currently supported'
  end
end
new(config) click to toggle source
# File lib/rflow/connection.rb, line 42
def initialize(config)
  @config = config
  @uuid = config.uuid
  @name = config.name
  @options = config.options
end

Public Instance Methods

connect_input!() click to toggle source

Subclass and implement to be able to handle future recv methods. Will only be called in the context of a running EventMachine reactor. @return [void]

# File lib/rflow/connection.rb, line 53
def connect_input!
  raise NotImplementedError, 'Raw connections do not support connect_input.  Please subclass and define a connect_input method.'
end
connect_output!() click to toggle source

Subclass and implement to be able to handle future send methods. Will only be called in the context of a running EventMachine reactor. @return [void]

# File lib/rflow/connection.rb, line 61
def connect_output!
  raise NotImplementedError, 'Raw connections do not support connect_output.  Please subclass and define a connect_output method.'
end
input_port_key() click to toggle source

If we are connected to an {Component::InputPort} subport, the key for that subport. @return [String]

# File lib/rflow/connection.rb, line 87
def input_port_key; config.input_port_key; end
output_port_key() click to toggle source

If we are connected to an {Component::OutputPort} subport, the key for that subport. @return [String]

# File lib/rflow/connection.rb, line 91
def output_port_key; config.output_port_key; end
recv_callback() click to toggle source

Parent component will set this attribute if it expects to receive messages. {Connection} subclass should call it (recv_callback.call(message)) when it gets a new message, which will be transmitted back to the parent component's {Component#process_message} method. Subclass is responsible for deserializing whatever was on the wire into a {RFlow::Message} object. @return [Proc]

# File lib/rflow/connection.rb, line 81
def recv_callback
  @recv_callback ||= Proc.new {|message|}
end
send_message(message) click to toggle source

Subclass and implement to handle outgoing messages. The message will be a {RFlow::Message} object and the subclasses are expected to marshal it up into something that will be unmarshalled on the other side. @return [void]

# File lib/rflow/connection.rb, line 70
def send_message(message)
  raise NotImplementedError, 'Raw connections do not support send_message.  Please subclass and define a send_message method.'
end