Class: RJR::Nodes::Multi
Overview
Multiple node definition, allows a developer to easily multiplex transport mechanisms to serve JSON-RPC requests over.
All nodes used locally will share the same dispatcher so that json-rpc methods only need to be registered once, with the multi-node itself.
This node does not support client operations (eg send_msg, invoke, and notify)
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Return the nodes.
Attributes inherited from RJR::Node
#connection_event_handlers, #dispatcher, #message_headers, #node_id
Instance Method Summary collapse
-
#<<(node) ⇒ Object
Add node to multinode.
-
#initialize(args = {}) ⇒ Multi
constructor
MultiNode initializer.
-
#listen ⇒ Object
Instruct Node to start listening for and dispatching rpc requests.
- #to_s ⇒ Object
Methods inherited from RJR::Node
#clear_event_handlers, em, #em, #halt, #indirect?, indirect?, #join, #node_type, #on, persistent?, #persistent?, tp, #tp
Constructor Details
#initialize(args = {}) ⇒ Multi
MultiNode initializer
51 52 53 54 55 56 57 |
# File 'lib/rjr/nodes/multi.rb', line 51 def initialize(args = {}) super(args) @nodes = [] args[:nodes].each { |n| self << n } if args[:nodes] end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Return the nodes
46 47 48 |
# File 'lib/rjr/nodes/multi.rb', line 46 def nodes @nodes end |
Instance Method Details
#<<(node) ⇒ Object
Add node to multinode
65 66 67 68 |
# File 'lib/rjr/nodes/multi.rb', line 65 def <<(node) node.dispatcher = @dispatcher @nodes << node end |
#listen ⇒ Object
Instruct Node to start listening for and dispatching rpc requests
Implementation of RJR::Node#listen
74 75 76 77 78 79 |
# File 'lib/rjr/nodes/multi.rb', line 74 def listen @nodes.each { |node| node.listen } self end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/rjr/nodes/multi.rb', line 59 def to_s "RJR::Nodes::Multi<#{@node_id}>" end |