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::NOTHING, cling = true) ⇒ Schedule
constructor
A new instance of Schedule.
- #join ⇒ Object
- #ps ⇒ Object
- #register(task) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(log = Log::NOTHING, cling = true) ⇒ Schedule
TODO:
#/DEV New scheduling types like ‘at’, ‘once’ is required. The minimum time period for cron is 1 minute and it’s not suitable for unit testing, thus its better to introduce new types which allows to schedule some task once or at particular time period like in next 200ms). For cron expressions we should define separate test suite which will test in parallel without blocking main CI process.
Returns a new instance of Schedule.
43 44 45 46 47 |
# File 'lib/lazylead/schedule.rb', line 43 def initialize(log = Log::NOTHING, cling = true) @log = log @cling = cling @trigger = Rufus::Scheduler.new end |
Instance Method Details
#join ⇒ Object
63 64 65 |
# File 'lib/lazylead/schedule.rb', line 63 def join @trigger.join if @cling end |
#ps ⇒ Object
61 |
# File 'lib/lazylead/schedule.rb', line 61 def ps; end |
#register(task) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/lazylead/schedule.rb', line 51 def register(task) raise "ll-002: task can't be a null" if task.nil? @trigger.cron task.cron do task.exec @log end @log.debug "Task scheduled: #{task}" end |
#stop ⇒ Object
69 70 71 |
# File 'lib/lazylead/schedule.rb', line 69 def stop @trigger.shutdown(:kill) end |