Class: Ticketing::Ticket
- Inherits:
-
Object
- Object
- Ticketing::Ticket
- Defined in:
- lib/ticketing/broker.rb
Overview
An acquired lock guard — release explicitly, or close for a background release. If the client dies, the server's lease frees it. 획득한 락 가드 — 명시 해제 또는 close(백그라운드 해제), 사망 시 lease가 정리.
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
The locked key.
-
#token ⇒ Object
readonly
Fencing token — strictly increases with every grant of any key.
Instance Method Summary collapse
-
#close ⇒ Object
Background release (fire-and-forget), like rust's drop.
-
#initialize(broker, conn, key, token) ⇒ Ticket
constructor
A new instance of Ticket.
-
#release ⇒ Object
Releases the lock; true if the server still held it.
- #to_s ⇒ Object
Constructor Details
#initialize(broker, conn, key, token) ⇒ Ticket
Returns a new instance of Ticket.
153 154 155 156 157 158 159 160 |
# File 'lib/ticketing/broker.rb', line 153 def initialize(broker, conn, key, token) @broker = broker @conn = conn @key = key @token = token @released = false @mutex = Mutex.new end |
Instance Attribute Details
#key ⇒ Object (readonly)
The locked key. 잠긴 키.
148 149 150 |
# File 'lib/ticketing/broker.rb', line 148 def key @key end |
#token ⇒ Object (readonly)
Fencing token — strictly increases with every grant of any key. 펜싱 토큰 — 모든 grant마다 단조 증가. 자원 측에서 낮은 토큰 거부.
151 152 153 |
# File 'lib/ticketing/broker.rb', line 151 def token @token end |
Instance Method Details
#close ⇒ Object
Background release (fire-and-forget), like rust's drop. 백그라운드 해제.
170 171 172 173 174 |
# File 'lib/ticketing/broker.rb', line 170 def close return if take_released! @broker.release_forget(@conn, @key) end |
#release ⇒ Object
Releases the lock; true if the server still held it. 해제 — 보유 중이었으면 true.
163 164 165 166 167 |
# File 'lib/ticketing/broker.rb', line 163 def release return false if take_released! @broker.release_loop(@conn, @key) end |
#to_s ⇒ Object
176 |
# File 'lib/ticketing/broker.rb', line 176 def to_s = "Ticket(key=#{@key}, token=#{@token})" |