Sha256: 7b0c4dc5736a893f7e17669055ad392389fd033d453e8c83fa61155749c53341

Contents?: true

Size: 1.44 KB

Versions: 16

Compression:

Stored size: 1.44 KB

Contents

module SplitIoClient
  class SplitFactory
    include SplitIoClient::Cache::Repositories
    include SplitIoClient::Cache::Stores

    attr_reader :adapter, :client, :manager

    def initialize(api_key, config_hash = {})
      @api_key = api_key
      @config = SplitConfig.new(config_hash)

      @cache_adapter = @config.cache_adapter

      @splits_repository = SplitsRepository.new(@cache_adapter, @config)
      @segments_repository = SegmentsRepository.new(@cache_adapter, @config)
      @impressions_repository = ImpressionsRepository.new(@config.impressions_adapter, @config)
      @metrics_repository = MetricsRepository.new(@config.metrics_adapter, @config)
      @events_repository = EventsRepository.new(@config.events_adapter, @config)

      @sdk_blocker = SDKBlocker.new(@config, @splits_repository, @segments_repository)
      @adapter = start!

      @client = SplitClient.new(@api_key, @config, @adapter, @splits_repository, @segments_repository, @impressions_repository, @metrics_repository, @events_repository)
      @manager = SplitManager.new(@api_key, @config, @adapter, @splits_repository)

      @sdk_blocker.block if @config.block_until_ready > 0
    end

    def start!
      SplitAdapter.new(@api_key, @config, @splits_repository, @segments_repository, @impressions_repository, @metrics_repository, @events_repository, @sdk_blocker)
    end

    def stop!
      @config.threads.each { |_, t| t.exit }
    end

    alias resume! start!
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
splitclient-rb-5.1.0-java lib/splitclient-rb/split_factory.rb
splitclient-rb-5.1.0 lib/splitclient-rb/split_factory.rb
splitclient-rb-5.1.0.pre.rc1-java lib/splitclient-rb/split_factory.rb
splitclient-rb-5.1.0.pre.rc1 lib/splitclient-rb/split_factory.rb
splitclient-rb-5.0.3-java lib/splitclient-rb/split_factory.rb
splitclient-rb-5.0.3 lib/splitclient-rb/split_factory.rb
splitclient-rb-5.0.3.pre.rc1-java lib/splitclient-rb/split_factory.rb
splitclient-rb-5.0.3.pre.rc1 lib/splitclient-rb/split_factory.rb
splitclient-rb-5.0.2-java lib/splitclient-rb/split_factory.rb
splitclient-rb-5.0.2 lib/splitclient-rb/split_factory.rb
splitclient-rb-5.0.2.pre.rc1-java lib/splitclient-rb/split_factory.rb
splitclient-rb-5.0.2.pre.rc1 lib/splitclient-rb/split_factory.rb
splitclient-rb-5.0.1-java lib/splitclient-rb/split_factory.rb
splitclient-rb-5.0.1 lib/splitclient-rb/split_factory.rb
splitclient-rb-5.0.1.pre.rc1-java lib/splitclient-rb/split_factory.rb
splitclient-rb-5.0.1.pre.rc1 lib/splitclient-rb/split_factory.rb