Module: Vx::Common::AMQP::Consumer::Configuration
- Included in:
- ClassMethods
- Defined in:
- lib/vx/common/amqp/consumer/configuration.rb
Constant Summary collapse
- @@consumer_configuration_lock =
Mutex.new
Instance Method Summary collapse
- #ack(value = nil) ⇒ Object
- #bind_options ⇒ Object
- #consumer_configuration ⇒ Object
- #consumer_id ⇒ Object
- #consumer_name ⇒ Object
- #content_type(value = nil) ⇒ Object
- #headers(values = nil, &block) ⇒ Object
- #model(value = nil) ⇒ Object
- #reset_consumer_configuration! ⇒ Object
- #routing_key(name = nil, &block) ⇒ Object
Instance Method Details
#ack(value = nil) ⇒ Object
71 72 73 74 |
# File 'lib/vx/common/amqp/consumer/configuration.rb', line 71 def ack(value = nil) consumer_configuration.ack = value unless value == nil consumer_configuration.ack end |
#bind_options ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/vx/common/amqp/consumer/configuration.rb', line 88 def consumer_configuration. || @@consumer_configuration_lock.synchronize do opts = {} opts[:routing_key] = routing_key if routing_key opts[:headers] = headers if headers consumer_configuration. = opts end end |
#consumer_configuration ⇒ Object
11 12 13 |
# File 'lib/vx/common/amqp/consumer/configuration.rb', line 11 def consumer_configuration @consumer_configuration || reset_consumer_configuration! end |
#consumer_id ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/vx/common/amqp/consumer/configuration.rb', line 80 def consumer_id if cid = Thread.current[:vx_amqp_consumer_id] "#{consumer_name}.#{cid}" else consumer_name end end |
#consumer_name ⇒ Object
76 77 78 |
# File 'lib/vx/common/amqp/consumer/configuration.rb', line 76 def consumer_name consumer_configuration.consumer_name end |
#content_type(value = nil) ⇒ Object
66 67 68 69 |
# File 'lib/vx/common/amqp/consumer/configuration.rb', line 66 def content_type(value = nil) consumer_configuration.content_type = value if value consumer_configuration.content_type end |
#headers(values = nil, &block) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/vx/common/amqp/consumer/configuration.rb', line 52 def headers(values = nil, &block) val = block || values if val consumer_configuration.headers = val else value_maybe_proc consumer_configuration.headers end end |
#model(value = nil) ⇒ Object
61 62 63 64 |
# File 'lib/vx/common/amqp/consumer/configuration.rb', line 61 def model(value = nil) consumer_configuration.model = value unless value == nil consumer_configuration.model end |
#reset_consumer_configuration! ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vx/common/amqp/consumer/configuration.rb', line 15 def reset_consumer_configuration! @@consumer_configuration_lock.synchronize do @consumer_configuration = OpenStruct.new(exchange: OpenStruct.new(options: {}), queue: OpenStruct.new(options: {}), consumer_name: make_consumer_name, ack: false, content_type: nil) end end |
#routing_key(name = nil, &block) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/vx/common/amqp/consumer/configuration.rb', line 43 def routing_key(name = nil, &block) val = block || name if val consumer_configuration.routing_key = val else value_maybe_proc consumer_configuration.routing_key end end |