Module: Cloudmunda::Worker
- Defined in:
- lib/cloudmunda/cli/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.
-
#runs_in_development ⇒ Object
Returns the value of attribute runs_in_development.
-
#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.
7 8 9 |
# File 'lib/cloudmunda/cli/worker.rb', line 7 def client @client end |
#max_jobs_to_activate ⇒ Object
Returns the value of attribute max_jobs_to_activate.
7 8 9 |
# File 'lib/cloudmunda/cli/worker.rb', line 7 def max_jobs_to_activate @max_jobs_to_activate end |
#poll_interval ⇒ Object
Returns the value of attribute poll_interval.
7 8 9 |
# File 'lib/cloudmunda/cli/worker.rb', line 7 def poll_interval @poll_interval end |
#runs_in_development ⇒ Object
Returns the value of attribute runs_in_development.
7 8 9 |
# File 'lib/cloudmunda/cli/worker.rb', line 7 def runs_in_development @runs_in_development end |
#timeout ⇒ Object
Returns the value of attribute timeout.
7 8 9 |
# File 'lib/cloudmunda/cli/worker.rb', line 7 def timeout @timeout end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/cloudmunda/cli/worker.rb', line 7 def type @type end |
#variables ⇒ Object
Returns the value of attribute variables.
7 8 9 |
# File 'lib/cloudmunda/cli/worker.rb', line 7 def variables @variables end |
Class Method Details
.included(base) ⇒ Object
9 10 11 12 |
# File 'lib/cloudmunda/cli/worker.rb', line 9 def self.included(base) base.extend(ClassMethods) Cloudmunda.register_worker(base) end |
Instance Method Details
#complete_job(job, variables: {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/cloudmunda/cli/worker.rb', line 18 def complete_job(job, variables: {}) logger.info "Completed processing job #{job.type} #{job.key}" client.complete_job( jobKey: job.key, variables: Hash(variables).to_json ) end |
#fail_job(job, reason: '') ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cloudmunda/cli/worker.rb', line 26 def fail_job(job, reason: '') logger.error "Failed processing job #{job.type} #{job.key}: #{reason}" client.fail_job( jobKey: job.key, retries: job.retries - 1, errorMessage: reason ) rescue StandardError => e logger.error e. end |
#initialize(client) ⇒ Object
14 15 16 |
# File 'lib/cloudmunda/cli/worker.rb', line 14 def initialize(client) @client = client end |
#logger ⇒ Object
37 38 39 |
# File 'lib/cloudmunda/cli/worker.rb', line 37 def logger ::Cloudmunda.logger end |