Class: SplitIoClient::Cache::Fetchers::SplitFetcher
- Inherits:
-
Object
- Object
- SplitIoClient::Cache::Fetchers::SplitFetcher
- Defined in:
- lib/splitclient-rb/cache/fetchers/split_fetcher.rb
Instance Attribute Summary collapse
-
#splits_repository ⇒ Object
readonly
Returns the value of attribute splits_repository.
Instance Method Summary collapse
- #call ⇒ Object
- #fetch_splits(fetch_options = { cache_control_headers: false, till: nil }) ⇒ Object
-
#initialize(splits_repository, api_key, config, telemetry_runtime_producer) ⇒ SplitFetcher
constructor
A new instance of SplitFetcher.
- #stop_splits_thread ⇒ Object
Constructor Details
#initialize(splits_repository, api_key, config, telemetry_runtime_producer) ⇒ SplitFetcher
Returns a new instance of SplitFetcher.
7 8 9 10 11 12 13 |
# File 'lib/splitclient-rb/cache/fetchers/split_fetcher.rb', line 7 def initialize(splits_repository, api_key, config, telemetry_runtime_producer) @splits_repository = splits_repository @api_key = api_key @config = config @semaphore = Mutex.new @telemetry_runtime_producer = telemetry_runtime_producer end |
Instance Attribute Details
#splits_repository ⇒ Object (readonly)
Returns the value of attribute splits_repository.
5 6 7 |
# File 'lib/splitclient-rb/cache/fetchers/split_fetcher.rb', line 5 def splits_repository @splits_repository end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/splitclient-rb/cache/fetchers/split_fetcher.rb', line 15 def call if ENV['SPLITCLIENT_ENV'] == 'test' fetch_splits return end splits_thread end |
#fetch_splits(fetch_options = { cache_control_headers: false, till: nil }) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/splitclient-rb/cache/fetchers/split_fetcher.rb', line 24 def fetch_splits( = { cache_control_headers: false, till: nil }) @semaphore.synchronize do data = splits_since(@splits_repository.get_change_number, ) SplitIoClient::Helpers::RepositoryHelper.update_feature_flag_repository(@splits_repository, data[:splits], data[:till], @config) @splits_repository.set_segment_names(data[:segment_names]) @config.logger.debug("segments seen(#{data[:segment_names].length}): #{data[:segment_names].to_a}") if @config.debug_enabled { segment_names: data[:segment_names], success: true } end rescue StandardError => e @config.log_found_exception(__method__.to_s, e) { segment_names: [], success: false } end |
#stop_splits_thread ⇒ Object
39 40 41 |
# File 'lib/splitclient-rb/cache/fetchers/split_fetcher.rb', line 39 def stop_splits_thread SplitIoClient::Helpers::ThreadHelper.stop(:split_fetcher, @config) end |