class Legion::Extensions::Actors::Every

Public Class Methods

new(**_opts) click to toggle source
# File lib/legion/extensions/actors/every.rb, line 9
def initialize(**_opts)
  @timer = Concurrent::TimerTask.new(execution_interval: time, timeout_interval: timeout, run_now: run_now?) do
    use_runner? ? runner : manual
  end

  @timer.execute
rescue StandardError => e
  Legion::Logging.error e.message
  Legion::Logging.error e.backtrace
end

Public Instance Methods

action(**_opts) click to toggle source
# File lib/legion/extensions/actors/every.rb, line 32
def action(**_opts)
  Legion::Logging.warn 'An extension is using the default block from Legion::Extensions::Runners::Every'
end
cancel() click to toggle source
# File lib/legion/extensions/actors/every.rb, line 36
def cancel
  Legion::Logging.debug 'Cancelling Legion Timer'
  return true unless @timer.respond_to?(:shutdown)

  @timer.shutdown
rescue StandardError => e
  Legion::Logging.error e.message
  Legion::Logging.error e.backtrace
end
run_now?() click to toggle source
# File lib/legion/extensions/actors/every.rb, line 28
def run_now?
  false
end
time() click to toggle source
# File lib/legion/extensions/actors/every.rb, line 20
def time
  1
end
timeout() click to toggle source
# File lib/legion/extensions/actors/every.rb, line 24
def timeout
  5
end