Sha256: 801d1ca1fe2b73bc21b5fef2a103ce2b614e5dacd5d4f9bd532b192eba380bee
Contents?: true
Size: 1.38 KB
Versions: 26
Compression:
Stored size: 1.38 KB
Contents
module Shoryuken class DefaultWorkerRegistry < WorkerRegistry def initialize @workers = {} end def batch_receive_messages?(queue) !!(@workers[queue] && @workers[queue].get_shoryuken_options['batch']) end def clear @workers.clear end def fetch_worker(queue, message) worker_class = !message.is_a?(Array) && message.message_attributes && message.message_attributes['shoryuken_class'] && message.message_attributes['shoryuken_class'][:string_value] worker_class = begin worker_class.constantize rescue @workers[queue] end worker_class.new if worker_class end def queues @workers.keys end def register_worker(queue, clazz) if (worker_class = @workers[queue]) if worker_class.get_shoryuken_options['batch'] == true || clazz.get_shoryuken_options['batch'] == true fail ArgumentError, "Could not register #{clazz} for #{queue}, "\ "because #{worker_class} is already registered for this queue, "\ "and Shoryuken doesn't support a batchable worker for a queue with multiple workers" end end @workers[queue] = clazz end def workers(queue) [@workers.fetch(queue, [])].flatten end end end
Version data entries
26 entries across 26 versions & 1 rubygems