Module: Cloudmunda::Worker::ClassMethods
- Defined in:
- lib/cloudmunda/cli/worker.rb
Instance Method Summary collapse
-
#get_max_jobs_to_activate ⇒ Integer
Returns the maximum number of jobs to send to the worker for processing at once.
-
#get_name ⇒ String
Returns the worker’s name.
-
#get_poll_interval ⇒ Integer
Returns the interval duration in seconds between polls to the broker.
-
#get_runs_in_development ⇒ Boolean
Returns if this service task should run in development mode.
-
#get_timeout ⇒ Integer
Returns the time in seconds the worker has to process the job before the broker consider it as expired and can schedule it to another worker.
-
#get_type ⇒ String
Returns the type of service task the worker should subscribe to.
-
#get_variables_to_fetch ⇒ Array<String, Symbol>
Returns the worker’s variables to fetch from the broker when polling for new jobs.
-
#max_jobs_to_activate(max_jobs_to_activate) ⇒ Integer
Sets the maximum number of jobs to send to the worker for processing at once.
-
#poll_interval(poll_interval) ⇒ Integer
Sets the interval duration in seconds between polls to the broker.
-
#runs_in_development(runs_in_development) ⇒ Boolean
Sets if this service task runs in development mode or not.
-
#timeout(timeout) ⇒ Integer
Sets the time in seconds the worker has to process the job before the broker consider it as expired and can schedule it to another worker.
-
#type(type) ⇒ String
Sets the type of service task the worker should subscribe to.
-
#variables(variables) ⇒ Array<String, Symbol>
Sets the worker’s variables to fetch from the broker when polling for new jobs.
Instance Method Details
#get_max_jobs_to_activate ⇒ Integer
Returns the maximum number of jobs to send to the worker for processing at once. As jobs get completed by the worker, more jobs will be sent to the worker but always within this limit.
84 85 86 |
# File 'lib/cloudmunda/cli/worker.rb', line 84 def get_max_jobs_to_activate @max_jobs_to_activate || 1 end |
#get_name ⇒ String
Returns the worker’s name.
179 180 181 182 183 |
# File 'lib/cloudmunda/cli/worker.rb', line 179 def get_name name = self.name.gsub(/::/, ':') name.gsub!(/([^A-Z:])([A-Z])/) { "#{Regexp.last_match(1)}_#{Regexp.last_match(2)}" } name.downcase end |
#get_poll_interval ⇒ Integer
Returns the interval duration in seconds between polls to the broker.
105 106 107 |
# File 'lib/cloudmunda/cli/worker.rb', line 105 def get_poll_interval @poll_interval || 5 end |
#get_runs_in_development ⇒ Boolean
Returns if this service task should run in development mode.
172 173 174 |
# File 'lib/cloudmunda/cli/worker.rb', line 172 def get_runs_in_development @runs_in_development || false end |
#get_timeout ⇒ Integer
Returns the time in seconds the worker has to process the job before the broker consider it as expired and can schedule it to another worker.
128 129 130 |
# File 'lib/cloudmunda/cli/worker.rb', line 128 def get_timeout @timeout || 30 end |
#get_type ⇒ String
Returns the type of service task the worker should subscribe to.
59 60 61 |
# File 'lib/cloudmunda/cli/worker.rb', line 59 def get_type get_runs_in_development && Cloudmunda.env == 'development' ? "#{@type}-dev" : @type end |
#get_variables_to_fetch ⇒ Array<String, Symbol>
Returns the worker’s variables to fetch from the broker when polling for new jobs.
151 152 153 |
# File 'lib/cloudmunda/cli/worker.rb', line 151 def get_variables_to_fetch @variables.to_a end |
#max_jobs_to_activate(max_jobs_to_activate) ⇒ Integer
Sets the maximum number of jobs to send to the worker for processing at once. As jobs get completed by the worker, more jobs will be sent to the worker but always within this limit.
75 76 77 |
# File 'lib/cloudmunda/cli/worker.rb', line 75 def max_jobs_to_activate(max_jobs_to_activate) @max_jobs_to_activate = max_jobs_to_activate end |
#poll_interval(poll_interval) ⇒ Integer
Sets the interval duration in seconds between polls to the broker.
98 99 100 |
# File 'lib/cloudmunda/cli/worker.rb', line 98 def poll_interval(poll_interval) @poll_interval = poll_interval end |
#runs_in_development(runs_in_development) ⇒ Boolean
Sets if this service task runs in development mode or not.
165 166 167 |
# File 'lib/cloudmunda/cli/worker.rb', line 165 def runs_in_development(runs_in_development) @runs_in_development = runs_in_development end |
#timeout(timeout) ⇒ Integer
Sets the time in seconds the worker has to process the job before the broker consider it as expired and can schedule it to another worker.
120 121 122 |
# File 'lib/cloudmunda/cli/worker.rb', line 120 def timeout(timeout) @timeout = timeout end |
#type(type) ⇒ String
Sets the type of service task the worker should subscribe to.
52 53 54 |
# File 'lib/cloudmunda/cli/worker.rb', line 52 def type(type) @type = type end |
#variables(variables) ⇒ Array<String, Symbol>
Sets the worker’s variables to fetch from the broker when polling for new jobs.
143 144 145 |
# File 'lib/cloudmunda/cli/worker.rb', line 143 def variables(variables) @variables = variables end |