Class: Rabbit::Receiving::Receive
- Inherits:
-
Object
- Object
- Rabbit::Receiving::Receive
- Includes:
- Tainbox
- Defined in:
- lib/rabbit/receiving/receive.rb
Instance Method Summary collapse
- #after_hooks ⇒ Object
- #before_hooks ⇒ Object
- #call ⇒ Object
- #call_hooks(hooks) ⇒ Object
- #job_class ⇒ Object
- #job_configs ⇒ Object
- #log! ⇒ Object
- #message_info ⇒ Object
- #process_message ⇒ Object
- #queue ⇒ Object
- #queue_name ⇒ Object
Instance Method Details
#after_hooks ⇒ Object
45 46 47 |
# File 'lib/rabbit/receiving/receive.rb', line 45 def after_hooks Rabbit.config.after_receiving_hooks || [] end |
#before_hooks ⇒ Object
41 42 43 |
# File 'lib/rabbit/receiving/receive.rb', line 41 def before_hooks Rabbit.config.before_receiving_hooks || [] end |
#call ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rabbit/receiving/receive.rb', line 16 def call log! call_hooks(before_hooks) call_hooks(after_hooks) end |
#call_hooks(hooks) ⇒ Object
35 36 37 38 39 |
# File 'lib/rabbit/receiving/receive.rb', line 35 def call_hooks(hooks) hooks.each do |hook_proc| hook_proc.call(, ) end end |
#job_class ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/rabbit/receiving/receive.rb', line 67 def job_class Rabbit.config.receiving_job_class_callable&.call( message: , delivery_info: delivery_info, arguments: arguments, ) || Rabbit::Receiving::Job end |
#job_configs ⇒ Object
59 60 61 |
# File 'lib/rabbit/receiving/receive.rb', line 59 def job_configs queue.handler.additional_job_configs end |
#log! ⇒ Object
23 24 25 26 27 |
# File 'lib/rabbit/receiving/receive.rb', line 23 def log! Rabbit.config.receive_logger.debug( [, delivery_info, arguments].join(" / "), ) end |
#message_info ⇒ Object
49 50 51 52 53 |
# File 'lib/rabbit/receiving/receive.rb', line 49 def arguments.merge( delivery_info.slice(:exchange, :routing_key), ) end |
#process_message ⇒ Object
29 30 31 32 33 |
# File 'lib/rabbit/receiving/receive.rb', line 29 def job_class .set(queue: queue_name, **job_configs) .perform_later(, ) end |
#queue ⇒ Object
55 56 57 |
# File 'lib/rabbit/receiving/receive.rb', line 55 def queue @queue ||= Rabbit::Receiving::Queue.new(, arguments) end |
#queue_name ⇒ Object
63 64 65 |
# File 'lib/rabbit/receiving/receive.rb', line 63 def queue_name queue.name end |