Class: SplitIoClient::Cache::Stores::SDKBlocker

Inherits:
Object
  • Object
show all
Defined in:
lib/cache/stores/sdk_blocker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Parameters:

  • value

    the value to set the attribute segments_thread to.



9
10
11
# File 'lib/cache/stores/sdk_blocker.rb', line 9

def segments_thread=(value)
  @segments_thread = value
end

#splits_readyObject (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

Parameters:

  • value

    the value to set the attribute splits_thread to.



9
10
11
# File 'lib/cache/stores/sdk_blocker.rb', line 9

def splits_thread=(value)
  @splits_thread = value
end

Instance Method Details

#blockObject



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

Returns:

  • (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