Sha256: 01929fab9788104a655b3d7fb8cc2705f5cdf6976aba7ede6be423dc0574bbdd

Contents?: true

Size: 678 Bytes

Versions: 3

Compression:

Stored size: 678 Bytes

Contents

module Nucleus
  module Adapters
    # The TailStopper can be used to cancel a timer or an ongoing HTTP request,
    # e.g. when the underlying connection was terminated.
    class TailStopper
      include Nucleus::Logging

      def initialize(polling, method_to_stop)
        @polling = polling
        @method_to_stop = method_to_stop
      end

      # Stop the tailing
      # @return [void]
      def stop
        log.debug('Stop tail updates, connection was closed')
        begin
          @polling.method(@method_to_stop).call
        rescue
          log.debug('Ignore error while closing connection')
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nucleus-0.3.1 lib/nucleus/core/adapter_extensions/tail_stopper.rb
nucleus-0.2.0 lib/nucleus/core/adapter_extensions/tail_stopper.rb
nucleus-0.1.0 lib/nucleus/core/adapter_extensions/tail_stopper.rb