Class: RFlow::Connection
- Inherits:
-
Object
- Object
- RFlow::Connection
- Defined in:
- lib/rflow/connection.rb
Direct Known Subclasses
RFlow::Connections::ZMQConnection, ForwardToInputPort, ForwardToOutputPort, MessageCollectingConnection
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#recv_callback ⇒ Object
Parent component will set this attribute if it expects to recieve messages.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Class Method Summary collapse
Instance Method Summary collapse
-
#connect_input! ⇒ Object
Subclass and implement to be able to handle future ‘recv’ methods.
-
#connect_output! ⇒ Object
Subclass and implement to be able to handle future ‘send’ methods.
-
#initialize(config) ⇒ Connection
constructor
A new instance of Connection.
- #input_port_key ⇒ Object
- #output_port_key ⇒ Object
-
#send_message(message) ⇒ Object
Subclass and implement to handle outgoing messages.
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. end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
18 19 20 |
# File 'lib/rflow/connection.rb', line 18 def config @config end |
#name ⇒ Object
Returns the value of attribute name.
18 19 20 |
# File 'lib/rflow/connection.rb', line 18 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
18 19 20 |
# File 'lib/rflow/connection.rb', line 18 def @options end |
#recv_callback ⇒ Object
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 |
#uuid ⇒ Object
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
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
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_key ⇒ Object
63 |
# File 'lib/rflow/connection.rb', line 63 def input_port_key; config.input_port_key; end |
#output_port_key ⇒ Object
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
49 50 51 |
# File 'lib/rflow/connection.rb', line 49 def () raise NotImplementedError, 'Raw connections do not support send_message. Please subclass and define a send_message method.' end |