Class: Vx::Lib::Consumer::Configuration

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

Constant Summary collapse

DEBUG =
'VX_CONSUMER_DEBUG'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



16
17
18
# File 'lib/vx/lib/consumer/configuration.rb', line 16

def initialize
  reset!
end

Instance Attribute Details

#buildersObject

Returns the value of attribute builders.



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

def builders
  @builders
end

#content_typeObject

Returns the value of attribute content_type.



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

def content_type
  @content_type
end

#debugObject

Returns the value of attribute debug.



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

def debug
  @debug
end

#default_exchange_optionsObject

Returns the value of attribute default_exchange_options.



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

def default_exchange_options
  @default_exchange_options
end

#default_exchange_typeObject

Returns the value of attribute default_exchange_type.



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

def default_exchange_type
  @default_exchange_type
end

#default_publish_optionsObject

Returns the value of attribute default_publish_options.



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

def default_publish_options
  @default_publish_options
end

#default_queue_optionsObject

Returns the value of attribute default_queue_options.



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

def default_queue_options
  @default_queue_options
end

#heartbeatObject

Returns the value of attribute heartbeat.



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

def heartbeat
  @heartbeat
end

#instrumenterObject

Returns the value of attribute instrumenter.



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

def instrumenter
  @instrumenter
end

#on_error(&block) ⇒ Object

Returns the value of attribute on_error.



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

def on_error
  @on_error
end

#pool_timeoutObject

Returns the value of attribute pool_timeout.



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

def pool_timeout
  @pool_timeout
end

#prefetchObject

Returns the value of attribute prefetch.



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

def prefetch
  @prefetch
end

#spawn_attemptsObject

Returns the value of attribute spawn_attempts.



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

def spawn_attempts
  @spawn_attempts
end

Instance Method Details

#debug?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/vx/lib/consumer/configuration.rb', line 20

def debug?
  @debug ||= ENV[DEBUG]
end

#reset!Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/vx/lib/consumer/configuration.rb', line 33

def reset!
  @default_exchange_type = :topic
  @pool_timeout          = 0.5
  @heartbeat             = :server

  @spawn_attempts        = 1

  @content_type          = 'application/json'
  @prefetch              = 1

  @instrumenter          = nil
  @on_error              = ->(e, env){ nil }

  @builders = {
    pub: Vx::Common::Rack::Builder.new,
    sub: Vx::Common::Rack::Builder.new
  }

  @default_exchange_options = {
    durable:     true,
    auto_delete: false
  }

  @default_queue_options = {
    durable:      true,
    auto_delete:  false,
    exclusive:    false
  }

  @default_publish_options = {
  }
end

#use(target, middleware, *args) ⇒ Object



24
25
26
# File 'lib/vx/lib/consumer/configuration.rb', line 24

def use(target, middleware, *args)
  @builders[target].use middleware, *args
end