Sha256: 59715a747f036e57a3cc583a3bb3b83756df970467bcccc1747ecb5114e7c680
Contents?: true
Size: 1.24 KB
Versions: 6
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module SplitIoClient module SSE module Workers class SegmentsWorker def initialize(adapter, config, segments_repository) @adapter = adapter @config = config @segments_repository = segments_repository @queue = Queue.new perform_thread perform_passenger_forked if defined?(PhusionPassenger) end def add_to_queue(change_number, segment_name) item = { change_number: change_number, segment_name: segment_name } @queue.push(item) end private def perform while (item = @queue.pop) segment_name = item[:segment_name] change_number = item[:change_number] since = @segments_repository.get_change_number(segment_name) @adapter.segment_fetcher.fetch_segment(segment_name) unless since >= change_number end end def perform_thread @config.threads[:segment_update_worker] = Thread.new do perform end end def perform_passenger_forked PhusionPassenger.on_event(:starting_worker_process) { |forked| perform_thread if forked } end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems