Class: ActsAsTbackend::Config
- Inherits:
-
Object
- Object
- ActsAsTbackend::Config
- 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
-
#breaker_cooldown ⇒ Object
Returns the value of attribute breaker_cooldown.
-
#breaker_threshold ⇒ Object
Returns the value of attribute breaker_threshold.
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
-
#durability_default ⇒ Object
Returns the value of attribute durability_default.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#host ⇒ Object
Returns the value of attribute host.
-
#pool_checkout_timeout ⇒ Object
Returns the value of attribute pool_checkout_timeout.
-
#pool_size ⇒ Object
Returns the value of attribute pool_size.
-
#port ⇒ Object
Returns the value of attribute port.
-
#producer ⇒ Object
Returns the value of attribute producer.
-
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
-
#strict ⇒ Object
Returns the value of attribute strict.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
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_cooldown ⇒ Object
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_threshold ⇒ Object
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_timeout ⇒ Object
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_default ⇒ Object
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 |
#enabled ⇒ Object
Returns the value of attribute enabled.
14 15 16 |
# File 'lib/acts_as_tbackend/config.rb', line 14 def enabled @enabled end |
#host ⇒ Object
Returns the value of attribute host.
14 15 16 |
# File 'lib/acts_as_tbackend/config.rb', line 14 def host @host end |
#pool_checkout_timeout ⇒ Object
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_size ⇒ Object
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 |
#port ⇒ Object
Returns the value of attribute port.
14 15 16 |
# File 'lib/acts_as_tbackend/config.rb', line 14 def port @port end |
#producer ⇒ Object
Returns the value of attribute producer.
14 15 16 |
# File 'lib/acts_as_tbackend/config.rb', line 14 def producer @producer end |
#request_timeout ⇒ Object
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 |
#strict ⇒ Object
Returns the value of attribute strict.
14 15 16 |
# File 'lib/acts_as_tbackend/config.rb', line 14 def strict @strict end |
#token ⇒ Object
Returns the value of attribute token.
14 15 16 |
# File 'lib/acts_as_tbackend/config.rb', line 14 def token @token end |