Class: SplitIoClient::Cache::Stores::SDKBlocker
- Inherits:
-
Object
- Object
- SplitIoClient::Cache::Stores::SDKBlocker
- Defined in:
- lib/splitclient-rb/cache/stores/sdk_blocker.rb
Instance Attribute Summary collapse
-
#splits_repository ⇒ Object
readonly
Returns the value of attribute splits_repository.
Instance Method Summary collapse
- #block(time = nil) ⇒ Object
-
#initialize(splits_repository, segments_repository, config) ⇒ SDKBlocker
constructor
A new instance of SDKBlocker.
- #ready? ⇒ Boolean
- #sdk_internal_ready ⇒ Object
- #segments_ready! ⇒ Object
- #splits_ready! ⇒ Object
- #wait_unitil_internal_ready ⇒ Object
Constructor Details
#initialize(splits_repository, segments_repository, config) ⇒ SDKBlocker
Returns a new instance of SDKBlocker.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 10 def initialize(splits_repository, segments_repository, config) @splits_repository = splits_repository @segments_repository = segments_repository @config = config @internal_ready = Concurrent::CountDownLatch.new(1) if @config.standalone? @splits_repository.not_ready! @segments_repository.not_ready! end end |
Instance Attribute Details
#splits_repository ⇒ Object (readonly)
Returns the value of attribute splits_repository.
8 9 10 |
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 8 def splits_repository @splits_repository end |
Instance Method Details
#block(time = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 36 def block(time = nil) begin timeout = time || @config.block_until_ready Timeout::timeout(timeout) do sleep 0.1 until ready? end rescue Timeout::Error fail SDKBlockerTimeoutExpiredException, 'SDK start up timeout expired' end @config.logger.info('SplitIO SDK is ready') end |
#ready? ⇒ Boolean
49 50 51 52 |
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 49 def ready? return true if @config.consumer? @splits_repository.ready? && @segments_repository.ready? end |
#sdk_internal_ready ⇒ Object
54 55 56 |
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 54 def sdk_internal_ready @internal_ready.count_down end |
#segments_ready! ⇒ Object
29 30 31 32 33 34 |
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 29 def segments_ready! if !ready? @segments_repository.ready! @config.logger.info('segments are ready') end end |
#splits_ready! ⇒ Object
22 23 24 25 26 27 |
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 22 def splits_ready! if !ready? @splits_repository.ready! @config.logger.info('splits are ready') end end |
#wait_unitil_internal_ready ⇒ Object
58 59 60 |
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 58 def wait_unitil_internal_ready @internal_ready.wait end |