Class: Aggro::Locator
- Inherits:
-
Object
- Object
- Aggro::Locator
- Defined in:
- lib/aggro/locator.rb
Overview
Public: Locates the nodes responsible for a given entity ID.
Instance Method Summary collapse
-
#initialize(id) ⇒ Locator
constructor
A new instance of Locator.
- #local? ⇒ Boolean
- #nodes ⇒ Object
- #primary_node ⇒ Object
- #secondary_nodes ⇒ Object
Constructor Details
#initialize(id) ⇒ Locator
Returns a new instance of Locator.
4 5 6 |
# File 'lib/aggro/locator.rb', line 4 def initialize(id) @id = id end |
Instance Method Details
#local? ⇒ Boolean
8 9 10 |
# File 'lib/aggro/locator.rb', line 8 def local? primary_node.is_a? LocalNode end |
#nodes ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/aggro/locator.rb', line 12 def nodes current_node_list_state = Aggro.node_list.state if @last_node_list_state == current_node_list_state @nodes ||= Aggro.node_list.nodes_for(@id) else @last_node_list_state = current_node_list_state @nodes = Aggro.node_list.nodes_for(@id) end end |
#primary_node ⇒ Object
24 25 26 |
# File 'lib/aggro/locator.rb', line 24 def primary_node nodes.first end |
#secondary_nodes ⇒ Object
28 29 30 |
# File 'lib/aggro/locator.rb', line 28 def secondary_nodes nodes[1..-1] end |