Module: ActionSubscriber::MarchHare::Subscriber

Includes:
Logging, Subscriber
Included in:
RouteSet
Defined in:
lib/action_subscriber/march_hare/subscriber.rb

Instance Method Summary collapse

Methods included from Subscriber

#safely_restart_subscriber

Methods included from Logging

initialize_logger, logger, #logger, logger=

Instance Method Details

#cancel_consumers!Object



7
8
9
10
11
12
13
# File 'lib/action_subscriber/march_hare/subscriber.rb', line 7

def cancel_consumers!
  # Cancel any non-cancelled consumers.
  march_hare_consumers.reject(&:cancelled?).each(&:cancel)
  ::ActionSubscriber::ThreadPools.threadpools.each do |name, threadpool|
    threadpool.shutdown
  end
end

#march_hare_consumersObject



15
16
17
# File 'lib/action_subscriber/march_hare/subscriber.rb', line 15

def march_hare_consumers
  @march_hare_consumers ||= []
end

#setup_subscriptions!Object



19
20
21
22
23
24
25
26
27
# File 'lib/action_subscriber/march_hare/subscriber.rb', line 19

def setup_subscriptions!
  fail ::RuntimeError, "you cannot setup queues multiple times, this should only happen once at startup" unless subscriptions.empty?
  routes.each do |route|
    subscriptions << {
      :route => route,
      :queue => setup_queue(route),
    }
  end
end

#start_subscribers!Object



29
30
31
32
33
# File 'lib/action_subscriber/march_hare/subscriber.rb', line 29

def start_subscribers!
  subscriptions.each do |subscription|
    start_subscriber_for_subscription(subscription)
  end
end