Class: RFlow::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/rflow/connection.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Connection

Returns a new instance of Connection.



24
25
26
27
28
29
# File 'lib/rflow/connection.rb', line 24

def initialize(config)
  @config = config
  @uuid = config.uuid
  @name = config.name
  @options = config.options
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



18
19
20
# File 'lib/rflow/connection.rb', line 18

def config
  @config
end

#nameObject

Returns the value of attribute name.



18
19
20
# File 'lib/rflow/connection.rb', line 18

def name
  @name
end

#optionsObject

Returns the value of attribute options.



18
19
20
# File 'lib/rflow/connection.rb', line 18

def options
  @options
end

#recv_callbackObject

Parent component will set this attribute if it expects to recieve 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 process_message method. Sublcass is responsible for deserializing whatever was on the wire into a RFlow::Message object



59
60
61
# File 'lib/rflow/connection.rb', line 59

def recv_callback
  @recv_callback
end

#uuidObject

Returns the value of attribute uuid.



18
19
20
# File 'lib/rflow/connection.rb', line 18

def uuid
  @uuid
end

Class Method Details

.build(config) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/rflow/connection.rb', line 6

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

Instance Method Details

#connect_input!Object

Subclass and implement to be able to handle future ‘recv’ methods. Will only be called in the context of a running EventMachine reactor

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/rflow/connection.rb', line 34

def connect_input!
  raise NotImplementedError, 'Raw connections do not support connect_input.  Please subclass and define a connect_input method.'
end

#connect_output!Object

Subclass and implement to be able to handle future ‘send’ methods. Will only be called in the context of a running EventMachine reactor

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/rflow/connection.rb', line 41

def connect_output!
  raise NotImplementedError, 'Raw connections do not support connect_output.  Please subclass and define a connect_output method.'
end

#input_port_keyObject



63
# File 'lib/rflow/connection.rb', line 63

def input_port_key; config.input_port_key; end

#output_port_keyObject



64
# File 'lib/rflow/connection.rb', line 64

def output_port_key; config.output_port_key; end

#send_message(message) ⇒ Object

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

Raises:

  • (NotImplementedError)


49
50
51
# File 'lib/rflow/connection.rb', line 49

def send_message(message)
  raise NotImplementedError, 'Raw connections do not support send_message.  Please subclass and define a send_message method.'
end