Class: AMQP::ConsumerTagGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/amqp/consumer_tag_generator.rb

Instance Method Summary collapse

Instance Method Details

#generateString

Returns Generated consumer tag.

Returns:

  • (String)

    Generated consumer tag



9
10
11
# File 'lib/amqp/consumer_tag_generator.rb', line 9

def generate
  "#{Kernel.rand}-#{Time.now.to_i * 1000}-#{Kernel.rand(999_999_999_999)}"
end

#generate_for(queue) ⇒ String

Returns Generated consumer tag.

Returns:

  • (String)

    Generated consumer tag

Raises:

  • (ArgumentError)


14
15
16
17
18
# File 'lib/amqp/consumer_tag_generator.rb', line 14

def generate_for(queue)
  raise ArgumentError, "argument must respond to :name" unless queue.respond_to?(:name)

  "#{queue.name}-#{Time.now.to_i * 1000}-#{Kernel.rand(999_999_999_999)}"
end