Class: Nucleus::Adapters::TailStopper

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/nucleus/core/adapter_extensions/tail_stopper.rb

Overview

The TailStopper can be used to cancel a timer or an ongoing HTTP request, e.g. when the underlying connection was terminated.

Instance Method Summary collapse

Methods included from Logging

configure_logger_for, #log, logger_for

Constructor Details

#initialize(polling, method_to_stop) ⇒ TailStopper

Returns a new instance of TailStopper.



8
9
10
11
# File 'lib/nucleus/core/adapter_extensions/tail_stopper.rb', line 8

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

Instance Method Details

#stopvoid

This method returns an undefined value.

Stop the tailing



15
16
17
18
19
20
21
22
# File 'lib/nucleus/core/adapter_extensions/tail_stopper.rb', line 15

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