Class: MultipleMan::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/multiple_man/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/multiple_man/configuration.rb', line 19

def initialize
  self.topic_name = "multiple_man"
  self.app_name = Rails.application.class.parent.to_s if defined?(Rails)
  self.enabled = true
  self.worker_concurrency = 1
  self.reraise_errors = true
  self.prefetch_size = 100
  self.connection_recovery = {
    time_before_reconnect: 0.2,
    time_between_retries: 0.8,
    max_retries: 5
  }
  self.bunny_opts = {}
  self.exchange_opts = {}
  self.publisher_confirms = false

  @subscriber_registry = Subscribers::Registry.new
end

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name.



12
13
14
# File 'lib/multiple_man/configuration.rb', line 12

def app_name
  @app_name
end

#bunny_optsObject

Returns the value of attribute bunny_opts.



12
13
14
# File 'lib/multiple_man/configuration.rb', line 12

def bunny_opts
  @bunny_opts
end

#connectionObject

Returns the value of attribute connection.



12
13
14
# File 'lib/multiple_man/configuration.rb', line 12

def connection
  @connection
end

#connection_recoveryObject

Returns the value of attribute connection_recovery.



12
13
14
# File 'lib/multiple_man/configuration.rb', line 12

def connection_recovery
  @connection_recovery
end

#enabledObject

Returns the value of attribute enabled.



12
13
14
# File 'lib/multiple_man/configuration.rb', line 12

def enabled
  @enabled
end

#error_handlerObject

Returns the value of attribute error_handler.



12
13
14
# File 'lib/multiple_man/configuration.rb', line 12

def error_handler
  @error_handler
end

#exchange_optsObject

Returns the value of attribute exchange_opts.



12
13
14
# File 'lib/multiple_man/configuration.rb', line 12

def exchange_opts
  @exchange_opts
end

#loggerObject



42
43
44
# File 'lib/multiple_man/configuration.rb', line 42

def logger
  @logger ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
end

#prefetch_sizeObject

Returns the value of attribute prefetch_size.



12
13
14
# File 'lib/multiple_man/configuration.rb', line 12

def prefetch_size
  @prefetch_size
end

#publisher_confirmsObject

Returns the value of attribute publisher_confirms.



12
13
14
# File 'lib/multiple_man/configuration.rb', line 12

def publisher_confirms
  @publisher_confirms
end

#queue_nameObject

Returns the value of attribute queue_name.



12
13
14
# File 'lib/multiple_man/configuration.rb', line 12

def queue_name
  @queue_name
end

#reraise_errorsObject

Returns the value of attribute reraise_errors.



12
13
14
# File 'lib/multiple_man/configuration.rb', line 12

def reraise_errors
  @reraise_errors
end

#subscriber_registryObject (readonly)

Returns the value of attribute subscriber_registry.



11
12
13
# File 'lib/multiple_man/configuration.rb', line 11

def subscriber_registry
  @subscriber_registry
end

#topic_nameObject

Returns the value of attribute topic_name.



12
13
14
# File 'lib/multiple_man/configuration.rb', line 12

def topic_name
  @topic_name
end

#worker_concurrencyObject

Returns the value of attribute worker_concurrency.



12
13
14
# File 'lib/multiple_man/configuration.rb', line 12

def worker_concurrency
  @worker_concurrency
end

Instance Method Details

#listenersObject



50
51
52
# File 'lib/multiple_man/configuration.rb', line 50

def listeners
  subscriber_registry.subscriptions
end

#on_error(&block) ⇒ Object



46
47
48
# File 'lib/multiple_man/configuration.rb', line 46

def on_error(&block)
  @error_handler = block
end

#register_listener(listener) ⇒ Object



54
55
56
# File 'lib/multiple_man/configuration.rb', line 54

def register_listener(listener)
  subscriber_registry.register(listener)
end