module Beez::Worker::ClassMethods
Public Instance Methods
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.
@return [Integer]
# File lib/beez/worker.rb, line 82 def get_max_jobs_to_activate @max_jobs_to_activate || 1 end
Returns the worker's name.
@return [String]
# File lib/beez/worker.rb, line 156 def get_name name = self.name.gsub(/::/, ':') name.gsub!(/([^A-Z:])([A-Z])/) { "#{$1}_#{$2}" } name.downcase end
Returns the interval duration in seconds between polls to the broker.
@return [Integer]
# File lib/beez/worker.rb, line 103 def get_poll_interval @poll_interval || 5 end
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.
@return [Integer]
# File lib/beez/worker.rb, line 126 def get_timeout @timeout || 30 end
Returns the type of service task the worker should subscribe to.
@return [String]
# File lib/beez/worker.rb, line 57 def get_type @type end
Returns the worker's variables to fetch from the broker when polling for new jobs.
@return [Array<String, Symbol>]
# File lib/beez/worker.rb, line 149 def get_variables_to_fetch @variables.to_a end
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.
@example
class MyWorker include ::Beez::Worker max_jobs_to_activate 5 end
@param [Integer] max_jobs_to_activate
@return [Integer]
# File lib/beez/worker.rb, line 73 def max_jobs_to_activate(max_jobs_to_activate) @max_jobs_to_activate = max_jobs_to_activate end
Sets the interval duration in seconds between polls to the broker.
@example
class MyWorker include ::Beez::Worker poll_interval 5 end
@param [Integer] poll_interval
@return [Integer]
# File lib/beez/worker.rb, line 96 def poll_interval(poll_interval) @poll_interval = poll_interval end
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.
@example
class MyWorker include ::Beez::Worker timeout 30 end
@param [Integer] timeout @return [Integer]
# File lib/beez/worker.rb, line 118 def timeout(timeout) @timeout = timeout end
Sets the type of service task the worker should subscribe to.
@example
class MyWorker include ::Beez::Worker type "some-service-task-type" end
@param [String] type @return [String]
# File lib/beez/worker.rb, line 50 def type(type) @type = type end
Sets the worker's variables to fetch from the broker when polling for new jobs.
@example
class MyWorker include ::Beez::Worker variables [:foo, :bar] end
@param [Array<String, Symbol>] variables @return [Array<String, Symbol>]
# File lib/beez/worker.rb, line 141 def variables(variables) @variables = variables end