Sha256: 000c21ba3a225f72ddca496729f2780bd916ec7d17931d50c2fe3b15e9c90b18

Contents?: true

Size: 1.16 KB

Versions: 38

Compression:

Stored size: 1.16 KB

Contents

require 'thread'
require 'timeout'

module SplitIoClient
  module Cache
    module Stores
      class SDKBlocker
        attr_reader :splits_repository
        attr_writer :splits_thread, :segments_thread

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

          @splits_repository.not_ready!
          @segments_repository.not_ready!
        end

        def splits_ready!
          @splits_repository.ready!
        end

        def segments_ready!
          @segments_repository.ready!
        end

        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

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

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
splitclient-rb-6.2.0.pre.rc1-java lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.2.0.pre.rc1 lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.1.0-java lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.1.0 lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.1.0.pre.rc2-java lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.1.0.pre.rc2 lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.1.0.pre.rc1-java lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.1.0.pre.rc1 lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.0.1-java lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.0.1 lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.0.1.pre.rc2-java lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.0.1.pre.rc2 lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.0.1.pre.rc1-java lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.0.1.pre.rc1 lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.0.0-java lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-6.0.0 lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-5.1.3.pre.rc4-java lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-5.1.3.pre.rc4 lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-5.1.3.pre.rc3-java lib/splitclient-rb/cache/stores/sdk_blocker.rb
splitclient-rb-5.1.3.pre.rc3 lib/splitclient-rb/cache/stores/sdk_blocker.rb