Class: Ticketing::Topology

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

Overview

Shared cluster view: addresses + leader hint. Plain ivars are safe under the GVL. 공유 클러스터 뷰(주소 + 리더 힌트) — GVL 하에서 단순 대입은 안전.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(addrs) ⇒ Topology

Returns a new instance of Topology.



47
48
49
50
# File 'lib/ticketing/connection.rb', line 47

def initialize(addrs)
  @addrs = addrs
  @leader = -1
end

Instance Attribute Details

#addrsObject (readonly)

Returns the value of attribute addrs.



45
46
47
# File 'lib/ticketing/connection.rb', line 45

def addrs
  @addrs
end

#leaderObject (readonly)

Returns the value of attribute leader.



45
46
47
# File 'lib/ticketing/connection.rb', line 45

def leader
  @leader
end

Instance Method Details

#clear_leader_if(index) ⇒ Object



55
56
57
# File 'lib/ticketing/connection.rb', line 55

def clear_leader_if(index)
  @leader = -1 if @leader == index
end

#set_leader(addr) ⇒ Object

Map a M(Moved) address to a leader hint. M 주소 → 리더 힌트.



53
# File 'lib/ticketing/connection.rb', line 53

def set_leader(addr) = @leader = @addrs.index(addr) || -1