def start
      @mutex.synchronize do
        return if started?

        @status = STARTED

        thread = Thread.new do
          begin
            while started?
              unless @channels.empty?
                poll
                @stats.success += 1
                @stats.failed = 0
              end

              sleep interval
            end
          rescue StandardError => e
            @stats.failed += 1
            warn("#{e.class} #{e.message}: #{e.backtrace.join("\n")}")
            sleep interval
            retry
          ensure
            stop
          end
        end

        thread.abort_on_exception = true
      end

      self
    end
def start
      @mutex.synchronize do
        return if started?

        @status = STARTED

        thread = Thread.new do
          begin
            while started?
              unless @channels.empty?
                poll
                @stats.success += 1
                @stats.failed = 0
              end

              sleep interval
            end
          rescue StandardError => e
            @stats.failed += 1
            warn("#{e.class} #{e.message}: #{e.backtrace.join("\n")}")
            sleep interval
            retry
          ensure
            stop
          end
        end

        thread.abort_on_exception = true
      end

      self
    end
@param base_url [String] Base URL of the message_bus server to connect to
 @param enable_long_polling [Boolean] Enable long polling
 @param enable_chunked_encoding [Boolean] Enable chunk encoding
 @param min_poll_interval [Float, Integer] Min poll interval when long polling in seconds
 @param max_poll_interval [Float, Integer] Max poll interval when long polling in seconds.
   When requests fail, the client will backoff and this is the upper limit.
 @param background_callback_interval [Float, Integer] Interval to poll when
   when polling in seconds.
 @param headers [Hash] extra HTTP headers to be set on the polling requests.

 @return [Object] Instance of MessageBus::HTTPClient
 Starts a background thread that polls the message bus endpoint
 for the given base_url.

 Intervals for long polling can be configured via min_poll_interval and
 max_poll_interval.

 Intervals for polling can be configured via background_callback_interval.

 @return [Object] Instance of MessageBus::HTTPClient