Class: TypedBus::Configuration
- Inherits:
-
Object
- Object
- TypedBus::Configuration
- Defined in:
- lib/typed_bus/configuration.rb
Overview
Holds configurable defaults for the message bus system.
Three-tier cascade: Global → Bus → Channel.
Each tier can override the one above using explicit values.
The sentinel :use_default means "inherit from the tier above."
Constant Summary collapse
- DEFAULTS =
{ timeout: 30, max_pending: nil, throttle: 0.0, logger: nil, log_level: Logger::INFO }.freeze
Instance Attribute Summary collapse
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_pending ⇒ Object
Returns the value of attribute max_pending.
-
#throttle ⇒ Object
Returns the value of attribute throttle.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #initialize_copy(_source) ⇒ Object
-
#resolve(timeout: :use_default, max_pending: :use_default, throttle: :use_default) ⇒ Hash
Merge overrides on top of this configuration's values.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
30 31 32 33 34 35 36 |
# File 'lib/typed_bus/configuration.rb', line 30 def initialize @timeout = DEFAULTS[:timeout] @max_pending = DEFAULTS[:max_pending] @throttle = DEFAULTS[:throttle] @logger = DEFAULTS[:logger] @log_level = DEFAULTS[:log_level] end |
Instance Attribute Details
#log_level ⇒ Object
Returns the value of attribute log_level.
28 29 30 |
# File 'lib/typed_bus/configuration.rb', line 28 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
28 29 30 |
# File 'lib/typed_bus/configuration.rb', line 28 def logger @logger end |
#max_pending ⇒ Object
Returns the value of attribute max_pending.
27 28 29 |
# File 'lib/typed_bus/configuration.rb', line 27 def max_pending @max_pending end |
#throttle ⇒ Object
Returns the value of attribute throttle.
27 28 29 |
# File 'lib/typed_bus/configuration.rb', line 27 def throttle @throttle end |
#timeout ⇒ Object
Returns the value of attribute timeout.
27 28 29 |
# File 'lib/typed_bus/configuration.rb', line 27 def timeout @timeout end |
Instance Method Details
#initialize_copy(_source) ⇒ Object
67 68 69 70 |
# File 'lib/typed_bus/configuration.rb', line 67 def initialize_copy(_source) # All fields are scalars or intentionally shared (Logger). # No deep-copy needed. end |
#resolve(timeout: :use_default, max_pending: :use_default, throttle: :use_default) ⇒ Hash
Merge overrides on top of this configuration's values.
Parameters set to :use_default inherit from this config.
59 60 61 62 63 64 65 |
# File 'lib/typed_bus/configuration.rb', line 59 def resolve(timeout: :use_default, max_pending: :use_default, throttle: :use_default) { timeout: timeout == :use_default ? @timeout : timeout, max_pending: max_pending == :use_default ? @max_pending : max_pending, throttle: throttle == :use_default ? @throttle : throttle } end |