Class: Emque::Consuming::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/emque/consuming/configuration.rb', line 13

def initialize
  @app_name                = ""
  @auto_shutdown           = false
  @delayed_message_workers = 1
  @enable_delayed_message  = false
  @error_handlers          = []
  @error_limit             = 5
  @error_expiration        = 3600 # 60 minutes
  @log_level               = nil
  @log_formatter           = nil
  @retryable_errors        = []
  @retryable_error_limit   = 3
  @status_port             = 10000
  @status_host             = "0.0.0.0"
  @status                  = :off # :on
  @socket_path             = "tmp/emque.sock"
  @shutdown_handlers       = []
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def adapter
  @adapter
end

#app_nameObject

Returns the value of attribute app_name.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def app_name
  @app_name
end

#auto_shutdownObject

Returns the value of attribute auto_shutdown.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def auto_shutdown
  @auto_shutdown
end

#delayed_message_workersObject

Returns the value of attribute delayed_message_workers.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def delayed_message_workers
  @delayed_message_workers
end

#enable_delayed_messageObject

Returns the value of attribute enable_delayed_message.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def enable_delayed_message
  @enable_delayed_message
end

#envObject



32
33
34
# File 'lib/emque/consuming/configuration.rb', line 32

def env
  Emque::Consuming.application.emque_env
end

#error_expirationObject

Returns the value of attribute error_expiration.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def error_expiration
  @error_expiration
end

#error_handlersObject

Returns the value of attribute error_handlers.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def error_handlers
  @error_handlers
end

#error_limitObject

Returns the value of attribute error_limit.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def error_limit
  @error_limit
end

#log_formatterObject



44
45
46
# File 'lib/emque/consuming/configuration.rb', line 44

def log_formatter
  @log_formatter ||= ::Logger::Formatter.new
end

#log_levelObject



40
41
42
# File 'lib/emque/consuming/configuration.rb', line 40

def log_level
  @log_level ||= Logger::INFO
end

#retryable_error_limitObject

Returns the value of attribute retryable_error_limit.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def retryable_error_limit
  @retryable_error_limit
end

#retryable_errorsObject

Returns the value of attribute retryable_errors.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def retryable_errors
  @retryable_errors
end

#shutdown_handlersObject

Returns the value of attribute shutdown_handlers.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def shutdown_handlers
  @shutdown_handlers
end

#socket_pathObject

Returns the value of attribute socket_path.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def socket_path
  @socket_path
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def status
  @status
end

#status_hostObject

Returns the value of attribute status_host.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def status_host
  @status_host
end

#status_portObject

Returns the value of attribute status_port.



6
7
8
# File 'lib/emque/consuming/configuration.rb', line 6

def status_port
  @status_port
end

Instance Method Details

#env_varObject



36
37
38
# File 'lib/emque/consuming/configuration.rb', line 36

def env_var
  @env
end

#set_adapter(name, options = {}) ⇒ Object



48
49
50
# File 'lib/emque/consuming/configuration.rb', line 48

def set_adapter(name, options = {})
  @adapter = Emque::Consuming::Adapter.new(name, options)
end

#to_hshObject Also known as: to_h



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/emque/consuming/configuration.rb', line 52

def to_hsh
  {}.tap { |config|
    [
      :app_name,
      :adapter,
      :auto_shutdown,
      :delayed_message_workers,
      :env,
      :enable_delayed_message,
      :error_handlers,
      :error_limit,
      :error_expiration,
      :log_level,
      :retryable_errors,
      :retryable_error_limit,
      :status_port,
      :status_host,
      :status,
      :socket_path,
      :shutdown_handlers
    ].each { |attr|
      config[attr] = send(attr)
    }
  }
end