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
-
#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.
- #run(options = {}, &block) ⇒ Object
-
#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.
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() {} 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( = {}, &block) = () interval = .delete(:every) scheduler_opts = .delete(:scheduler) || {} ## Keep this for compatibility. # Note: :first_in inside the :scheduler hash will override this. rufus_opt = { first_in: [:first_in] } rufus_opt.merge!(scheduler_opts) event_name = .delete(:event) block.call if block_given? Context.new(interval, rufus_opt, event_name, , 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, ) OK end |