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(config, splits_repository, segments_repository) ⇒ SDKBlocker

Returns a new instance of SDKBlocker.



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

def initialize(config, splits_repository, segments_repository)
  @config = config
  @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_repositoryObject (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

#blockObject



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

def block
  begin
    Timeout::timeout(@config.block_until_ready) 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')
  @splits_thread.run
  @segments_thread.run
end

#ready?Boolean

Returns:

  • (Boolean)


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

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

#segments_ready!Object



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

def segments_ready!
  @segments_repository.ready!
end

#splits_ready!Object



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

def splits_ready!
  @splits_repository.ready!
end