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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(splits_repository, segments_repository) ⇒ SDKBlocker

Returns a new instance of SDKBlocker.



10
11
12
13
14
15
16
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 10

def initialize(splits_repository, segments_repository)
  @splits_repository = splits_repository
  @segments_repository = segments_repository

  @splits_repository.not_ready!
  @segments_repository.not_ready!
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 ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 26

def block
  begin
    Timeout::timeout(SplitIoClient.configuration.block_until_ready) do
      sleep 0.1 until ready?
    end
  rescue Timeout::Error
    fail SDKBlockerTimeoutExpiredException, 'SDK start up timeout expired'
  end

  SplitIoClient.configuration.logger.info('SplitIO SDK is ready')
  SplitIoClient.configuration.threads[:split_store].run
  SplitIoClient.configuration.threads[:segment_store].run
end

#ready? ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 40

def ready?
  @splits_repository.ready? && @segments_repository.ready?
end

#segments_ready! ⇒ Object



22
23
24
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 22

def segments_ready!
  @segments_repository.ready!
end

#splits_ready! ⇒ Object



18
19
20
# File 'lib/splitclient-rb/cache/stores/sdk_blocker.rb', line 18

def splits_ready!
  @splits_repository.ready!
end