Class: Proletariat::Manager

Inherits:
Concurrent::Actor::RestartingContext
  • Object
show all
Defined in:
lib/proletariat/manager.rb

Overview

Public: Maintains a pool of worker threads and a RabbitMQ subscriber

thread. Uses information from the worker class to generate queue
config.

Instance Method Summary collapse

Constructor Details

#initialize(worker_class) ⇒ Manager

Public: Creates a new Manager instance.

worker_class - A subclass of Proletariat::Worker to handle messages.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/proletariat/manager.rb', line 9

def initialize(worker_class)
  @workers = worker_class.pool(Proletariat.worker_threads, object_id)

  @subscriber = Subscriber.spawn!(
    name: "#{worker_class.to_s}_subscriber_#{object_id}",
    supervise: true,
    args: [
      workers,
      generate_queue_config(worker_class),
      get_exception_handler_class(worker_class)
    ]
  )
end