Module: Beez::Worker::ClassMethods
- Defined in:
- lib/beez/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_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.
-
#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.
80 81 82 |
# File 'lib/beez/worker.rb', line 80 def get_max_jobs_to_activate @max_jobs_to_activate || 1 end |
#get_name ⇒ String
Returns the worker’s name.
154 155 156 157 158 |
# File 'lib/beez/worker.rb', line 154 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.
101 102 103 |
# File 'lib/beez/worker.rb', line 101 def get_poll_interval @poll_interval || 5 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.
124 125 126 |
# File 'lib/beez/worker.rb', line 124 def get_timeout @timeout || 30 end |
#get_type ⇒ String
Returns the type of service task the worker should subscribe to.
55 56 57 |
# File 'lib/beez/worker.rb', line 55 def get_type @type end |
#get_variables_to_fetch ⇒ Array<String, Symbol>
Returns the worker’s variables to fetch from the broker when polling for new jobs.
147 148 149 |
# File 'lib/beez/worker.rb', line 147 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.
71 72 73 |
# File 'lib/beez/worker.rb', line 71 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.
94 95 96 |
# File 'lib/beez/worker.rb', line 94 def poll_interval(poll_interval) @poll_interval = poll_interval 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.
116 117 118 |
# File 'lib/beez/worker.rb', line 116 def timeout(timeout) @timeout = timeout end |
#type(type) ⇒ String
Sets the type of service task the worker should subscribe to.
48 49 50 |
# File 'lib/beez/worker.rb', line 48 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.
139 140 141 |
# File 'lib/beez/worker.rb', line 139 def variables(variables) @variables = variables end |