Class: Lazylead::Schedule
- Inherits:
-
Object
- Object
- Lazylead::Schedule
- Defined in:
- lib/lazylead/schedule.rb
Overview
The tasks schedule
- Author
-
Yurii Dubinka ([email protected])
- Copyright
-
Copyright © 2019-2020 Yurii Dubinka
- License
-
MIT
Instance Method Summary collapse
-
#initialize(log: Log.new, cling: true, trigger: Rufus::Scheduler.new) ⇒ Schedule
constructor
A new instance of Schedule.
- #join ⇒ Object
- #ps ⇒ Object
- #register(task) ⇒ Object
- #stop ⇒ Object
Constructor Details
Instance Method Details
#join ⇒ Object
69 70 71 |
# File 'lib/lazylead/schedule.rb', line 69 def join @trigger.join if @cling end |
#ps ⇒ Object
65 66 67 |
# File 'lib/lazylead/schedule.rb', line 65 def ps @log.debug "#{self}#ps" end |
#register(task) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/lazylead/schedule.rb', line 46 def register(task) raise "ll-002: task can't be a null" if task.nil? @trigger.method(task.type).call(task.unit) do ActiveRecord::Base.connection_pool.with_connection do if task.props.key? "no_logs" ORM::Retry.new(task, @log).exec else ORM::Retry.new( ORM::Verbose.new(task, @log), @log ).exec end end end @log.debug "Task scheduled: #{task}" end |
#stop ⇒ Object
75 76 77 |
# File 'lib/lazylead/schedule.rb', line 75 def stop @trigger.shutdown(:kill) end |