Class: ActsAsTbackend::Config

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

Overview

Process-wide configuration for the TBackend connector. Defaults come from ENV so the same code runs in dev / CI / prod without edits.

ActsAsTbackend.configure do |c|
c.host = "127.0.0.1"; c.port = 7401
c.token = ENV["TBACKEND_TOKEN"]
c.pool_size = 12                 # ~ Puma threads per process
c.durability_default = "accepted"
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/acts_as_tbackend/config.rb', line 25

def initialize
  @enabled = ENV.fetch("TBACKEND_ENABLED", "1") != "0"
  @host = ENV.fetch("TBACKEND_HOST", "127.0.0.1")
  @port = Integer(ENV.fetch("TBACKEND_PORT", 7401))
  @token = ENV["TBACKEND_TOKEN"]
  @connect_timeout = Float(ENV.fetch("TBACKEND_CONNECT_TIMEOUT", 1.0))
  @request_timeout = Float(ENV.fetch("TBACKEND_REQUEST_TIMEOUT", 2.0))
  @pool_size = Integer(ENV.fetch("TBACKEND_POOL_SIZE", 5))
  @pool_checkout_timeout = Float(ENV.fetch("TBACKEND_POOL_CHECKOUT_TIMEOUT", 1.0))
  @durability_default = ENV.fetch("TBACKEND_DURABILITY", "accepted")
  @strict = ENV["TBACKEND_STRICT"] == "1"
  @breaker_threshold = Integer(ENV.fetch("TBACKEND_BREAKER_THRESHOLD", 5))
  @breaker_cooldown = Float(ENV.fetch("TBACKEND_BREAKER_COOLDOWN", 5.0))
  @producer = ENV.fetch("TBACKEND_PRODUCER", "acts-as-tbackend")
end

Instance Attribute Details

#breaker_cooldownObject

Returns the value of attribute breaker_cooldown.



14
15
16
# File 'lib/acts_as_tbackend/config.rb', line 14

def breaker_cooldown
  @breaker_cooldown
end

#breaker_thresholdObject

Returns the value of attribute breaker_threshold.



14
15
16
# File 'lib/acts_as_tbackend/config.rb', line 14

def breaker_threshold
  @breaker_threshold
end

#connect_timeoutObject

Returns the value of attribute connect_timeout.



14
15
16
# File 'lib/acts_as_tbackend/config.rb', line 14

def connect_timeout
  @connect_timeout
end

#durability_defaultObject

Returns the value of attribute durability_default.



14
15
16
# File 'lib/acts_as_tbackend/config.rb', line 14

def durability_default
  @durability_default
end

#enabledObject

Returns the value of attribute enabled.



14
15
16
# File 'lib/acts_as_tbackend/config.rb', line 14

def enabled
  @enabled
end

#hostObject

Returns the value of attribute host.



14
15
16
# File 'lib/acts_as_tbackend/config.rb', line 14

def host
  @host
end

#pool_checkout_timeoutObject

Returns the value of attribute pool_checkout_timeout.



14
15
16
# File 'lib/acts_as_tbackend/config.rb', line 14

def pool_checkout_timeout
  @pool_checkout_timeout
end

#pool_sizeObject

Returns the value of attribute pool_size.



14
15
16
# File 'lib/acts_as_tbackend/config.rb', line 14

def pool_size
  @pool_size
end

#portObject

Returns the value of attribute port.



14
15
16
# File 'lib/acts_as_tbackend/config.rb', line 14

def port
  @port
end

#producerObject

Returns the value of attribute producer.



14
15
16
# File 'lib/acts_as_tbackend/config.rb', line 14

def producer
  @producer
end

#request_timeoutObject

Returns the value of attribute request_timeout.



14
15
16
# File 'lib/acts_as_tbackend/config.rb', line 14

def request_timeout
  @request_timeout
end

#strictObject

Returns the value of attribute strict.



14
15
16
# File 'lib/acts_as_tbackend/config.rb', line 14

def strict
  @strict
end

#tokenObject

Returns the value of attribute token.



14
15
16
# File 'lib/acts_as_tbackend/config.rb', line 14

def token
  @token
end