Sha256: cc31befafaf62e34d7a257672254394934375c002bfc4bbc22cf871d6cf796e5

Contents?: true

Size: 1.04 KB

Versions: 80

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module SplitIoClient
  module SSE
    class SSEHandler
      attr_reader :sse_client

      def initialize(config,
                     splits_worker,
                     segments_worker,
                     sse_client)
        @config = config
        @splits_worker = splits_worker
        @segments_worker = segments_worker
        @sse_client = sse_client
      end

      def start(token_jwt, channels)
        @sse_client.start("#{@config.streaming_service_url}?channels=#{channels}&v=1.1&accessToken=#{token_jwt}")
      end

      def stop
        @sse_client.close(Constants::PUSH_FORCED_STOP)
        stop_workers
      rescue StandardError => e
        @config.logger.debug("SSEHandler stop error: #{e.inspect}") if @config.debug_enabled
      end

      def connected?
        @sse_client&.connected? || false
      end

      def start_workers
        @splits_worker.start
        @segments_worker.start
      end

      def stop_workers
        @splits_worker.stop
        @segments_worker.stop
      end
    end
  end
end

Version data entries

80 entries across 80 versions & 1 rubygems

Version Path
splitclient-rb-8.5.0-java lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.5.0 lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.5.0.pre.rc1-java lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.5.0.pre.rc1 lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.4.1.pre.rc1-java lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.4.1.pre.rc1 lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.4.0-java lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.4.0 lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.4.0.pre.rc1-java lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.4.0.pre.rc1 lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.4.0.rc.1-java lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.4.0.rc.1 lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.3.2.pre.rc2-java lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.3.2.pre.rc2 lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.3.2.pre.rc1-java lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.3.2.pre.rc1 lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.3.1-java lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.3.1 lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.3.1.pre.rc1-java lib/splitclient-rb/sse/sse_handler.rb
splitclient-rb-8.3.1.pre.rc1 lib/splitclient-rb/sse/sse_handler.rb