class Sidekiq::Cluster::Monitors::Base

Attributes

pool[RW]
thread[RW]

Public Class Methods

new(pool) click to toggle source
# File lib/sidekiq/cluster/monitors/base.rb, line 10
def initialize(pool)
  self.pool = pool
  @last_logged_at = Time.now.to_i
end

Public Instance Methods

join() click to toggle source
# File lib/sidekiq/cluster/monitors/base.rb, line 20
def join
  thread.join if thread
end
log_periodically(msg, &block) click to toggle source
# File lib/sidekiq/cluster/monitors/base.rb, line 28
def log_periodically(msg, &block)
  t = Time.now.to_i
  if t - @last_logged_at > LOGGING_PERIOD
    pool.cli.info(msg) if msg
    Array(block.call).each do |result|
      pool.cli.info(result)
    end if block
    @last_logged_at = t
  end
end
monitor() click to toggle source
# File lib/sidekiq/cluster/monitors/base.rb, line 24
def monitor
  raise 'Abstract method'
end
start() click to toggle source
# File lib/sidekiq/cluster/monitors/base.rb, line 15
def start
  self.thread = Thread.new { self.monitor }
  self
end