Class: SolidRedis::SentinelState
- Inherits:
-
Object
- Object
- SolidRedis::SentinelState
- Defined in:
- lib/solid_redis/sentinel_state.rb
Constant Summary collapse
- SENTINEL_DELAY =
0.05
Instance Method Summary collapse
-
#initialize(specification) ⇒ SentinelState
constructor
A new instance of SentinelState.
- #reset ⇒ Object
- #resolve ⇒ Object
- #resolved? ⇒ Boolean
- #sentinel_endpoints ⇒ Object
Constructor Details
#initialize(specification) ⇒ SentinelState
Returns a new instance of SentinelState.
7 8 9 10 11 12 |
# File 'lib/solid_redis/sentinel_state.rb', line 7 def initialize(specification) @specification = specification @sentinels = specification.sentinel_endpoints.dup @resolved = nil @mutex = Mutex.new end |
Instance Method Details
#reset ⇒ Object
20 21 22 |
# File 'lib/solid_redis/sentinel_state.rb', line 20 def reset @mutex.synchronize { @resolved = nil } end |
#resolve ⇒ Object
14 15 16 17 18 |
# File 'lib/solid_redis/sentinel_state.rb', line 14 def resolve @mutex.synchronize do @resolved ||= resolve_target end end |
#resolved? ⇒ Boolean
24 25 26 |
# File 'lib/solid_redis/sentinel_state.rb', line 24 def resolved? @mutex.synchronize { !@resolved.nil? } end |
#sentinel_endpoints ⇒ Object
28 29 30 |
# File 'lib/solid_redis/sentinel_state.rb', line 28 def sentinel_endpoints @mutex.synchronize { @sentinels.dup } end |