Class: ABMeter::Config
- Inherits:
-
Object
- Object
- ABMeter::Config
- Defined in:
- lib/abmeter.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
API configuration.
-
#base_url ⇒ Object
Base URL for API endpoints.
-
#error_callback ⇒ Object
Proc called on errors.
-
#fetch_interval ⇒ Object
Seconds between config fetches (default: 60).
-
#flush_interval ⇒ Object
Performance tuning.
-
#log_level ⇒ Object
Log level (:debug, :info, :warn, :error).
-
#logger ⇒ Object
Logging and error handling.
-
#static_config ⇒ Object
Static configuration (alternative to API).
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #inspect ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
113 114 115 116 117 |
# File 'lib/abmeter.rb', line 113 def initialize @flush_interval = DEFAULT_FLUSH_INTERVAL @fetch_interval = DEFAULT_FETCH_INTERVAL @logger = detect_logger end |
Instance Attribute Details
#api_key ⇒ Object
API configuration
98 99 100 |
# File 'lib/abmeter.rb', line 98 def api_key @api_key end |
#base_url ⇒ Object
Base URL for API endpoints
99 100 101 |
# File 'lib/abmeter.rb', line 99 def base_url @base_url end |
#error_callback ⇒ Object
Proc called on errors
111 112 113 |
# File 'lib/abmeter.rb', line 111 def error_callback @error_callback end |
#fetch_interval ⇒ Object
Seconds between config fetches (default: 60)
106 107 108 |
# File 'lib/abmeter.rb', line 106 def fetch_interval @fetch_interval end |
#flush_interval ⇒ Object
Performance tuning
105 106 107 |
# File 'lib/abmeter.rb', line 105 def flush_interval @flush_interval end |
#log_level ⇒ Object
Log level (:debug, :info, :warn, :error)
110 111 112 |
# File 'lib/abmeter.rb', line 110 def log_level @log_level end |
#logger ⇒ Object
Logging and error handling
109 110 111 |
# File 'lib/abmeter.rb', line 109 def logger @logger end |
#static_config ⇒ Object
Static configuration (alternative to API)
102 103 104 |
# File 'lib/abmeter.rb', line 102 def static_config @static_config end |
Instance Method Details
#inspect ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/abmeter.rb', line 126 def inspect masked_key = api_key ? "#{api_key[0..3]}...#{api_key[-4..]}" : nil config_type = static_config ? 'static' : 'API' <<~CONFIG.strip #ABMeter::Config { type: #{config_type}, api_key: #{masked_key.inspect}, base_url: #{base_url.inspect}, flush_interval: #{flush_interval.inspect}, fetch_interval: #{fetch_interval.inspect}, logger: #{logger.class.name} } CONFIG end |
#validate! ⇒ Object
119 120 121 122 123 124 |
# File 'lib/abmeter.rb', line 119 def validate! unless static_config raise 'No API key provided' if api_key.nil? raise 'No API URL provided' if base_url.nil? end end |