Module: Beez::Worker
- Defined in:
- lib/beez/worker.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#max_jobs_to_activate ⇒ Object
Returns the value of attribute max_jobs_to_activate.
-
#poll_interval ⇒ Object
Returns the value of attribute poll_interval.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#type ⇒ Object
Returns the value of attribute type.
-
#variables ⇒ Object
Returns the value of attribute variables.
Class Method Summary collapse
Instance Method Summary collapse
- #complete_job(job, variables: {}) ⇒ Object
- #fail_job(job, reason: '') ⇒ Object
- #initialize(client) ⇒ Object
- #logger ⇒ Object
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/beez/worker.rb', line 5 def client @client end |
#max_jobs_to_activate ⇒ Object
Returns the value of attribute max_jobs_to_activate.
5 6 7 |
# File 'lib/beez/worker.rb', line 5 def max_jobs_to_activate @max_jobs_to_activate end |
#poll_interval ⇒ Object
Returns the value of attribute poll_interval.
5 6 7 |
# File 'lib/beez/worker.rb', line 5 def poll_interval @poll_interval end |
#timeout ⇒ Object
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/beez/worker.rb', line 5 def timeout @timeout end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/beez/worker.rb', line 5 def type @type end |
#variables ⇒ Object
Returns the value of attribute variables.
5 6 7 |
# File 'lib/beez/worker.rb', line 5 def variables @variables end |
Class Method Details
.included(base) ⇒ Object
7 8 9 10 |
# File 'lib/beez/worker.rb', line 7 def self.included(base) base.extend(ClassMethods) Beez.register_worker(base) end |
Instance Method Details
#complete_job(job, variables: {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/beez/worker.rb', line 16 def complete_job(job, variables: {}) client.complete_job( jobKey: job.key, variables: Hash(variables).to_json ) end |
#fail_job(job, reason: '') ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/beez/worker.rb', line 23 def fail_job(job, reason: '') client.fail_job( jobKey: job.key, retries: job.retries - 1, errorMessage: reason ) rescue StandardError => e logger.error e. end |
#initialize(client) ⇒ Object
12 13 14 |
# File 'lib/beez/worker.rb', line 12 def initialize(client) @client = client end |