Module: DashingContrib::RunnableJob

Extended by:
RunnableJob
Included in:
Jobs::DashingState, Jobs::Kue, Jobs::NagiosList, Jobs::PingdomSummary, Jobs::PingdomUptime, Jobs::Sidekiq, RunnableJob
Defined in:
lib/dashing-contrib/runnable_job.rb

Defined Under Namespace

Classes: Context

Constant Summary collapse

WARNING =
'warning'.freeze
CRITICAL =
'critical'.freeze
OK =
'ok'.freeze

Instance Method Summary collapse

Instance Method Details

#metrics(options) ⇒ Object

Overrides this method to fetch and generate metrics Return value should be the final metrics to be used in the user interface Arguments:

options :: options provided by caller in `run` method


60
61
62
# File 'lib/dashing-contrib/runnable_job.rb', line 60

def metrics(options)
  {}
end

#run(options = {}, &block) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/dashing-contrib/runnable_job.rb', line 39

def run(options = {}, &block)
  user_options = _merge_options(options)
  interval     = user_options.delete(:every)
  scheduler_opts = user_options.delete(:scheduler) || {}

  ## Keep this for compatibility.
  #   Note: :first_in inside the :scheduler hash will override this.
  rufus_opt = {
    first_in: user_options[:first_in]
  }
  rufus_opt.merge!(scheduler_opts)

  event_name   = user_options.delete(:event)
  block.call if block_given?
  Context.new(interval, rufus_opt, event_name, user_options, self).schedule!
end

#validate_state(metrics, user_options) ⇒ Object

Always return a common state, override this with your custom logic Common states are WARNING, CRITICAL, OK Arguments:

metrics :: calculated metrics provided `metrics` method
user_options :: hash provided by user options


69
70
71
# File 'lib/dashing-contrib/runnable_job.rb', line 69

def validate_state(metrics, user_options)
  OK
end