Module: Harmoniser::Subscriber::ClassMethods

Defined in:
lib/harmoniser/subscriber.rb

Instance Method Summary collapse

Instance Method Details

#harmoniser_subscriber(queue_name:, consumer_tag: nil, no_ack: true, exclusive: false, arguments: {}) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/harmoniser/subscriber.rb', line 11

def harmoniser_subscriber(queue_name:, consumer_tag: nil, no_ack: true, exclusive: false, arguments: {})
  @harmoniser_consumer_definition = Definition::Consumer.new(
    queue_name: queue_name,
    consumer_tag: consumer_tag,
    no_ack: no_ack,
    exclusive: exclusive,
    arguments: arguments
  )
end

#harmoniser_subscriber_start(channel: nil) ⇒ Object



21
22
23
24
25
# File 'lib/harmoniser/subscriber.rb', line 21

def harmoniser_subscriber_start(channel: nil)
  const_get(:HARMONISER_SUBSCRIBER_MUTEX).synchronize do
    @harmoniser_consumer ||= create_consumer(channel)
  end
end

#harmoniser_subscriber_stopObject



27
28
29
30
31
32
# File 'lib/harmoniser/subscriber.rb', line 27

def harmoniser_subscriber_stop
  return unless @harmoniser_consumer
  return unless @harmoniser_consumer.channel.open?

  @harmoniser_consumer.cancel
end

#harmoniser_subscriber_to_sObject



34
35
36
37
# File 'lib/harmoniser/subscriber.rb', line 34

def harmoniser_subscriber_to_s
  definition = @harmoniser_consumer_definition
  "<#{name}>: queue_name = `#{definition.queue_name}`, no_ack = `#{definition.no_ack}`"
end