Class: Rabbitek::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/rabbitek/config.rb

Overview

Rabbitek configuration

Constant Summary collapse

DEFAULTS =
{
  bunny_configuration: { hosts: 'localhost:5672', vhost: '/' },
  log_format: 'json',
  enable_newrelic: true,
  enable_sentry: true,
  logger: Logger.new(STDOUT),
  reloader: proc { |&block| block.call }
}.freeze

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



18
19
20
21
22
23
# File 'lib/rabbitek/config.rb', line 18

def initialize
  DEFAULTS.each { |k, v| public_send("#{k}=", v) }

  @client_hooks_config = []
  @server_hooks_config = []
end

Instance Method Details

#add_client_hook(hook_object, position = @client_hooks_config.size) ⇒ Object



25
26
27
# File 'lib/rabbitek/config.rb', line 25

def add_client_hook(hook_object, position = @client_hooks_config.size)
  @client_hooks_config.insert(position, hook_object)
end

#add_server_hook(hook_object, position = @server_hooks_config.size) ⇒ Object



29
30
31
# File 'lib/rabbitek/config.rb', line 29

def add_server_hook(hook_object, position = @server_hooks_config.size)
  @server_hooks_config.insert(position, hook_object)
end

#client_hooksObject



33
34
35
36
37
38
# File 'lib/rabbitek/config.rb', line 33

def client_hooks
  @client_hooks ||= begin
    @client_hooks_config << Client::Hooks::OpenTracing.new
    @client_hooks_config.reverse
  end
end

#server_hooksObject



40
41
42
43
44
45
46
# File 'lib/rabbitek/config.rb', line 40

def server_hooks
  @server_hooks ||= begin
    @server_hooks_config.unshift(Server::Hooks::TimeTracker.new)
    @server_hooks_config.push(Server::Hooks::OpenTracing.new, Server::Hooks::Retry.new)
    @server_hooks_config.reverse
  end
end