Class: Ask::Agent::SchedulerConfig
- Inherits:
-
Object
- Object
- Ask::Agent::SchedulerConfig
- Defined in:
- lib/ask/agent/scheduler.rb
Overview
DSL proxy used inside Configuration#scheduler. Collects task definitions that the Scheduler registers on start.
Instance Method Summary collapse
-
#cron(cron_expression, name: nil) { ... } ⇒ Object
Schedule a block to run on a cron schedule.
-
#each_task(&block) ⇒ Object
Yield each configured task definition.
-
#every(interval, name: nil) { ... } ⇒ Object
Schedule a block to run on a recurring interval.
-
#initialize(config) ⇒ SchedulerConfig
constructor
A new instance of SchedulerConfig.
Constructor Details
#initialize(config) ⇒ SchedulerConfig
Returns a new instance of SchedulerConfig.
141 142 143 144 |
# File 'lib/ask/agent/scheduler.rb', line 141 def initialize(config) @config = config @tasks = [] end |
Instance Method Details
#cron(cron_expression, name: nil) { ... } ⇒ Object
Schedule a block to run on a cron schedule.
161 162 163 164 |
# File 'lib/ask/agent/scheduler.rb', line 161 def cron(cron_expression, name: nil, &block) @tasks << { type: :cron, cron: cron_expression, name: name, block: block } self end |
#each_task(&block) ⇒ Object
Yield each configured task definition.
167 168 169 |
# File 'lib/ask/agent/scheduler.rb', line 167 def each_task(&block) @tasks.each(&block) end |
#every(interval, name: nil) { ... } ⇒ Object
Schedule a block to run on a recurring interval.
151 152 153 154 |
# File 'lib/ask/agent/scheduler.rb', line 151 def every(interval, name: nil, &block) @tasks << { type: :every, interval: interval, name: name, block: block } self end |