Class: Warren::Den

Inherits:
Object
  • Object
show all
Defined in:
lib/warren/den.rb

Overview

A Den is in charge of creating a Fox from a consumer configuration It handles the registration of dead-letter queues, and configuration of subscriptions and delay exchanges

Constant Summary collapse

DEFAULT_WORKER_COUNT =

The number of simultaneous workers generated by default

3

Instance Method Summary collapse

Constructor Details

#initialize(app_name, config, adaptor:) ⇒ Den

Create a Fox work pool.

Parameters:

  • app_name (String)

    The name of the application. Corresponds to the subscriptions config in ‘config/warren.yml`

  • config (Warren::Config::Consumers)

    A configuration object, loaded from ‘config/warren.yml` by default

  • adaptor (#recovered?, #handle, #env)

    An adaptor to handle framework specifics



23
24
25
26
27
28
# File 'lib/warren/den.rb', line 23

def initialize(app_name, config, adaptor:)
  @app_name = app_name
  @config = config
  @fox = nil
  @adaptor = adaptor
end

Instance Method Details

#foxObject



30
31
32
# File 'lib/warren/den.rb', line 30

def fox
  @fox ||= spawn_fox
end

#register_dead_letter_queuesVoid

Ensures the dead_letter queues and exchanges are registered.

Returns:

  • (Void)


38
39
40
41
42
43
44
45
46
# File 'lib/warren/den.rb', line 38

def register_dead_letter_queues
  config = dead_letter_config
  return unless config

  Warren.handler.with_channel do |channel|
    subscription = Warren::Subscription.new(channel: channel, config: config)
    subscription.activate!
  end
end