Class: SplitIoClient::Cache::Stores::SDKBlocker
- Inherits:
-
Object
- Object
- SplitIoClient::Cache::Stores::SDKBlocker
- Defined in:
- lib/cache/stores/sdk_blocker.rb
Instance Attribute Summary collapse
-
#segments_thread ⇒ Object
writeonly
Sets the attribute segments_thread.
-
#splits_ready ⇒ Object
readonly
Returns the value of attribute splits_ready.
-
#splits_thread ⇒ Object
writeonly
Sets the attribute splits_thread.
Instance Method Summary collapse
- #block ⇒ Object
-
#initialize(config) ⇒ SDKBlocker
constructor
A new instance of SDKBlocker.
- #ready? ⇒ Boolean
- #segments_ready! ⇒ Object
- #splits_ready! ⇒ Object
Constructor Details
#initialize(config) ⇒ SDKBlocker
Returns a new instance of SDKBlocker.
11 12 13 14 15 16 |
# File 'lib/cache/stores/sdk_blocker.rb', line 11 def initialize(config) @config = config @splits_ready = false @segments_ready = false end |
Instance Attribute Details
#segments_thread=(value) ⇒ Object (writeonly)
Sets the attribute segments_thread
9 10 11 |
# File 'lib/cache/stores/sdk_blocker.rb', line 9 def segments_thread=(value) @segments_thread = value end |
#splits_ready ⇒ Object (readonly)
Returns the value of attribute splits_ready.
8 9 10 |
# File 'lib/cache/stores/sdk_blocker.rb', line 8 def splits_ready @splits_ready end |
#splits_thread=(value) ⇒ Object (writeonly)
Sets the attribute splits_thread
9 10 11 |
# File 'lib/cache/stores/sdk_blocker.rb', line 9 def splits_thread=(value) @splits_thread = value end |
Instance Method Details
#block ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cache/stores/sdk_blocker.rb', line 26 def block begin Timeout::timeout(@config.block_until_ready) do sleep 0.1 until ready? sleep 0.1 until ready? end rescue Timeout::Error fail SDKBlockerTimeoutExpiredException, 'SDK start up timeout expired' end @config.logger.info('SplitIO SDK is ready') @splits_thread.run @segments_thread.run end |
#ready? ⇒ Boolean
41 42 43 |
# File 'lib/cache/stores/sdk_blocker.rb', line 41 def ready? @splits_ready && @segments_ready end |
#segments_ready! ⇒ Object
22 23 24 |
# File 'lib/cache/stores/sdk_blocker.rb', line 22 def segments_ready! @segments_ready = true end |
#splits_ready! ⇒ Object
18 19 20 |
# File 'lib/cache/stores/sdk_blocker.rb', line 18 def splits_ready! @splits_ready = true end |