Class: SplitIoClient::Api::Segments
- Defined in:
- lib/splitclient-rb/engine/api/segments.rb
Overview
Retrieves segment changes from the Split Backend
Instance Method Summary collapse
- #fetch_segments_by_names(names, fetch_options = { cache_control_headers: false, till: nil }) ⇒ Object
-
#initialize(api_key, segments_repository, config, telemetry_runtime_producer) ⇒ Segments
constructor
A new instance of Segments.
Methods inherited from Client
Constructor Details
#initialize(api_key, segments_repository, config, telemetry_runtime_producer) ⇒ Segments
Returns a new instance of Segments.
7 8 9 10 11 12 |
# File 'lib/splitclient-rb/engine/api/segments.rb', line 7 def initialize(api_key, segments_repository, config, telemetry_runtime_producer) super(config) @api_key = api_key @segments_repository = segments_repository @telemetry_runtime_producer = telemetry_runtime_producer end |
Instance Method Details
#fetch_segments_by_names(names, fetch_options = { cache_control_headers: false, till: nil }) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/splitclient-rb/engine/api/segments.rb', line 14 def fetch_segments_by_names(names, = { cache_control_headers: false, till: nil }) return if names.nil? || names.empty? names.each do |name| since = @segments_repository.get_change_number(name) loop do segment = fetch_segment_changes(name, since, ) @segments_repository.add_to_segment(segment) @config.split_logger.log_if_debug("Segment #{name} fetched before: #{since}, \ till: #{@segments_repository.get_change_number(name)}") break if since.to_i >= @segments_repository.get_change_number(name).to_i since = @segments_repository.get_change_number(name) end end end |