Module: Cloudtasker::Worker::ClassMethods
- Defined in:
- lib/cloudtasker/worker.rb,
lib/cloudtasker/testing.rb
Overview
Module class methods
Instance Method Summary collapse
-
#cloudtasker_options(opts = {}) ⇒ Hash
Set the worker runtime options.
-
#cloudtasker_options_hash ⇒ Hash
Return the worker runtime options.
-
#drain ⇒ Array<any>
Run all jobs related to this worker class.
-
#jobs ⇒ Array<Cloudtasker::Backend::MemoryTask>
Return all jobs related to this worker class.
-
#max_retries ⇒ Integer
Return the numbeer of times this worker will be retried.
-
#perform_async(*args) ⇒ Cloudtasker::CloudTask
Enqueue worker in the backgroundf.
-
#perform_at(time_at, *args) ⇒ Cloudtasker::CloudTask
Enqueue worker and delay processing.
-
#perform_in(interval, *args) ⇒ Cloudtasker::CloudTask
Enqueue worker and delay processing.
-
#schedule(args: nil, time_in: nil, time_at: nil, queue: nil) ⇒ Cloudtasker::CloudTask
Enqueue a worker with explicity options.
Instance Method Details
#cloudtasker_options(opts = {}) ⇒ Hash
Set the worker runtime options.
64 65 66 67 |
# File 'lib/cloudtasker/worker.rb', line 64 def (opts = {}) opt_list = opts&.map { |k, v| [k.to_sym, v] } || [] # symbolize @cloudtasker_options_hash = Hash[opt_list] end |
#cloudtasker_options_hash ⇒ Hash
Return the worker runtime options.
74 75 76 |
# File 'lib/cloudtasker/worker.rb', line 74 def @cloudtasker_options_hash || {} end |
#drain ⇒ Array<any>
Run all jobs related to this worker class.
128 129 130 |
# File 'lib/cloudtasker/testing.rb', line 128 def drain Backend::MemoryTask.drain(to_s) end |
#jobs ⇒ Array<Cloudtasker::Backend::MemoryTask>
Return all jobs related to this worker class.
119 120 121 |
# File 'lib/cloudtasker/testing.rb', line 119 def jobs Backend::MemoryTask.all(to_s) end |
#max_retries ⇒ Integer
Return the numbeer of times this worker will be retried.
132 133 134 |
# File 'lib/cloudtasker/worker.rb', line 132 def max_retries [:max_retries] || Cloudtasker.config.max_retries end |
#perform_async(*args) ⇒ Cloudtasker::CloudTask
Enqueue worker in the backgroundf.
85 86 87 |
# File 'lib/cloudtasker/worker.rb', line 85 def perform_async(*args) schedule(args: args) end |
#perform_at(time_at, *args) ⇒ Cloudtasker::CloudTask
Enqueue worker and delay processing.
109 110 111 |
# File 'lib/cloudtasker/worker.rb', line 109 def perform_at(time_at, *args) schedule(args: args, time_at: time_at) end |
#perform_in(interval, *args) ⇒ Cloudtasker::CloudTask
Enqueue worker and delay processing.
97 98 99 |
# File 'lib/cloudtasker/worker.rb', line 97 def perform_in(interval, *args) schedule(args: args, time_in: interval) end |
#schedule(args: nil, time_in: nil, time_at: nil, queue: nil) ⇒ Cloudtasker::CloudTask
Enqueue a worker with explicity options.
123 124 125 |
# File 'lib/cloudtasker/worker.rb', line 123 def schedule(args: nil, time_in: nil, time_at: nil, queue: nil) new(job_args: args, job_queue: queue).schedule(**{ interval: time_in, time_at: time_at }.compact) end |