def monitor_node
      failures = 0

      loop do
        begin
          break if @done
          sleep(WATCHER_SLEEP_TIME)
          latency = Benchmark.realtime { @node.ping }
          failures = 0
          notify(:available, latency)
          @node.wait
        rescue NodeUnavailableError => ex
          logger.debug("Failed to communicate with node #{@node}: #{ex.inspect}")
          failures += 1
          if failures >= @max_failures
            notify(:unavailable)
            failures = 0
          end
        rescue Exception => ex
          logger.error("Unexpected error while monitoring node #{@node}: #{ex.inspect}")
          logger.error(ex.backtrace.join("\n"))
        end
      end
    end
def monitor_node
      failures = 0

      loop do
        begin
          break if @done
          sleep(WATCHER_SLEEP_TIME)
          latency = Benchmark.realtime { @node.ping }
          failures = 0
          notify(:available, latency)
          @node.wait
        rescue NodeUnavailableError => ex
          logger.debug("Failed to communicate with node #{@node}: #{ex.inspect}")
          failures += 1
          if failures >= @max_failures
            notify(:unavailable)
            failures = 0
          end
        rescue Exception => ex
          logger.error("Unexpected error while monitoring node #{@node}: #{ex.inspect}")
          logger.error(ex.backtrace.join("\n"))
        end
      end
    end
Periodically monitors the redis node and reports state changes to
 the {RedisFailover::NodeManager}.