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
- #segments_ready! ⇒ Object
- #splits_ready! ⇒ Object
Constructor Details
#initialize(splits_repository, segments_repository, config) ⇒ SDKBlocker
10 11 12 13 14 15 16 17 18 19 |
# 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 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
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 35 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
48 49 50 51 |
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 48 def ready? return true if @config.consumer? @splits_repository.ready? && @segments_repository.ready? end |
#segments_ready! ⇒ Object
28 29 30 31 32 33 |
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 28 def segments_ready! if !ready? @segments_repository.ready! @config.logger.info('segments are ready') end end |
#splits_ready! ⇒ Object
21 22 23 24 25 26 |
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 21 def splits_ready! if !ready? @splits_repository.ready! @config.logger.info('splits are ready') end end |