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.



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

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

#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/splitclient-rb/cache/stores/sdk_blocker.rb', line 9

def segments_thread=(value)
  @segments_thread = value
end

#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

#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/splitclient-rb/cache/stores/sdk_blocker.rb', line 9

def splits_thread=(value)
  @splits_thread = value
end

Instance Method Details

#block ⇒ Object



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

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')
  @splits_thread.run
  @segments_thread.run
end

#ready? ⇒ Boolean

Returns:

  • (Boolean)


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

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

#segments_ready! ⇒ Object



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

def segments_ready!
  @segments_repository.ready!
end

#splits_ready! ⇒ Object



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

def splits_ready!
  @splits_repository.ready!
end