Sha256: 3bc50978f5505971cbdb06be61be2b0c064fb61ac118f1197fe04fe2ece30df4

Contents?: true

Size: 1.58 KB

Versions: 32

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

module SplitIoClient
  module SSE
    class NotificationProcessor
      def initialize(config, splits_worker, segments_worker)
        @config = config
        @splits_worker = splits_worker
        @segments_worker = segments_worker
      end

      def process(incoming_notification)
        case incoming_notification.data['type']
        when SSE::EventSource::EventTypes::SPLIT_UPDATE
          process_split_update(incoming_notification)
        when SSE::EventSource::EventTypes::SPLIT_KILL
          process_split_kill(incoming_notification)
        when SSE::EventSource::EventTypes::SEGMENT_UPDATE
          process_segment_update(incoming_notification)
        else
          @config.logger.error("Incorrect event type: #{incoming_notification}")
        end
      end

      private

      def process_split_update(notification)
        @config.logger.debug("SPLIT UPDATE notification received: #{notification}") if @config.debug_enabled
        @splits_worker.add_to_queue(notification)
      end

      def process_split_kill(notification)
        @config.logger.debug("SPLIT KILL notification received: #{notification}") if @config.debug_enabled
        @splits_worker.add_to_queue(notification)
      end

      def process_segment_update(notification)
        @config.logger.debug("SEGMENT UPDATE notification received: #{notification}") if @config.debug_enabled
        change_number = notification.data['changeNumber']
        segment_name = notification.data['segmentName']

        @segments_worker.add_to_queue(change_number, segment_name)
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
splitclient-rb-8.3.0.pre.rc1-java lib/splitclient-rb/sse/notification_processor.rb
splitclient-rb-8.3.0.pre.rc1 lib/splitclient-rb/sse/notification_processor.rb
splitclient-rb-8.2.0-java lib/splitclient-rb/sse/notification_processor.rb
splitclient-rb-8.2.0 lib/splitclient-rb/sse/notification_processor.rb
splitclient-rb-8.1.3.pre.rc4-java lib/splitclient-rb/sse/notification_processor.rb
splitclient-rb-8.1.3.pre.rc4 lib/splitclient-rb/sse/notification_processor.rb
splitclient-rb-8.1.3.pre.rc3-java lib/splitclient-rb/sse/notification_processor.rb
splitclient-rb-8.1.3.pre.rc3 lib/splitclient-rb/sse/notification_processor.rb
splitclient-rb-8.1.3.pre.rc2-java lib/splitclient-rb/sse/notification_processor.rb
splitclient-rb-8.1.3.pre.rc2 lib/splitclient-rb/sse/notification_processor.rb
splitclient-rb-8.1.3.pre.rc1-java lib/splitclient-rb/sse/notification_processor.rb
splitclient-rb-8.1.3.pre.rc1 lib/splitclient-rb/sse/notification_processor.rb