module QueueingRabbit::Job
Public Class Methods
extended(othermod)
click to toggle source
# File lib/queueing_rabbit/job.rb, line 6 def self.extended(othermod) othermod.extend(QueueingRabbit::InheritableClassVariables) othermod.class_eval do inheritable_variables :queue_name, :queue_options, :channel_options, :exchange_name, :exchange_options, :binding_declarations, :listening_options, :publishing_defaults end end
Public Instance Methods
bind(options = {})
click to toggle source
# File lib/queueing_rabbit/job.rb, line 36 def bind(options = {}) @binding_declarations ||= [] @binding_declarations << options end
bind_queue?()
click to toggle source
# File lib/queueing_rabbit/job.rb, line 45 def bind_queue? exchange_options[:type] && exchange_options[:type] != :default && !binding_declarations.empty? end
binding_declarations()
click to toggle source
# File lib/queueing_rabbit/job.rb, line 41 def binding_declarations @binding_declarations || [] end
demand_batch_publishing!()
click to toggle source
# File lib/queueing_rabbit/job.rb, line 66 def demand_batch_publishing! QueueingRabbit.follow_job_requirements(self) do |_, exchange, _| @shared_exchange = exchange end end
enqueue(payload, options = {})
click to toggle source
# File lib/queueing_rabbit/job.rb, line 72 def enqueue(payload, options = {}) publish(payload, options, :enqueue) end
listen(options = {})
click to toggle source
# File lib/queueing_rabbit/job.rb, line 55 def listen(options = {}) @listening_options ||= {} @listening_options.update(options) end
Also aliased as: subscribe
listening_options()
click to toggle source
# File lib/queueing_rabbit/job.rb, line 51 def listening_options @listening_options || {} end
publishing_defaults()
click to toggle source
# File lib/queueing_rabbit/job.rb, line 61 def publishing_defaults @publishing_defaults ||= {} {:routing_key => queue_name.to_s}.merge(@publishing_defaults) end
queue(*args)
click to toggle source
# File lib/queueing_rabbit/job.rb, line 17 def queue(*args) @queue_options ||= {} name, options = extract_name_and_options(*args) @queue_name = name if name @queue_options.update(options) if options end
queue_name()
click to toggle source
# File lib/queueing_rabbit/job.rb, line 24 def queue_name @queue_name || (self.name.split('::')[-1] if self.name) end
queue_options()
click to toggle source
# File lib/queueing_rabbit/job.rb, line 28 def queue_options @queue_options || {} end
queue_size()
click to toggle source
# File lib/queueing_rabbit/job.rb, line 32 def queue_size QueueingRabbit.queue_size(self) end