Class: Flagstack::Configuration
- Inherits:
-
Object
- Object
- Flagstack::Configuration
- Defined in:
- lib/flagstack/configuration.rb
Instance Attribute Summary collapse
-
#debug_output ⇒ Object
Logging.
-
#instrumenter ⇒ Object
Instrumentation (for monitoring systems).
-
#local_adapter ⇒ Object
Local adapter for fallback/caching.
-
#logger ⇒ Object
Logging.
-
#open_timeout ⇒ Object
HTTP settings.
-
#read_timeout ⇒ Object
HTTP settings.
-
#sync_interval ⇒ Object
Sync settings.
-
#sync_method ⇒ Object
Sync settings.
-
#telemetry_enabled ⇒ Object
Telemetry settings.
-
#telemetry_interval ⇒ Object
Telemetry settings.
-
#token ⇒ Object
Authentication.
-
#url ⇒ Object
Server.
-
#write_timeout ⇒ Object
HTTP settings.
Instance Method Summary collapse
- #environment_from_token ⇒ Object
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #instrument(name, payload = {}, &block) ⇒ Object
- #log(message, level: :debug) ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
29 30 31 32 33 34 35 36 |
# File 'lib/flagstack/configuration.rb', line 29 def initialize( = {}) setup_auth() setup_http() setup_sync() setup_telemetry() setup_logging() setup_instrumentation() end |
Instance Attribute Details
#debug_output ⇒ Object
Logging
24 25 26 |
# File 'lib/flagstack/configuration.rb', line 24 def debug_output @debug_output end |
#instrumenter ⇒ Object
Instrumentation (for monitoring systems)
27 28 29 |
# File 'lib/flagstack/configuration.rb', line 27 def instrumenter @instrumenter end |
#local_adapter ⇒ Object
Local adapter for fallback/caching
18 19 20 |
# File 'lib/flagstack/configuration.rb', line 18 def local_adapter @local_adapter end |
#logger ⇒ Object
Logging
24 25 26 |
# File 'lib/flagstack/configuration.rb', line 24 def logger @logger end |
#open_timeout ⇒ Object
HTTP settings
12 13 14 |
# File 'lib/flagstack/configuration.rb', line 12 def open_timeout @open_timeout end |
#read_timeout ⇒ Object
HTTP settings
12 13 14 |
# File 'lib/flagstack/configuration.rb', line 12 def read_timeout @read_timeout end |
#sync_interval ⇒ Object
Sync settings
15 16 17 |
# File 'lib/flagstack/configuration.rb', line 15 def sync_interval @sync_interval end |
#sync_method ⇒ Object
Sync settings
15 16 17 |
# File 'lib/flagstack/configuration.rb', line 15 def sync_method @sync_method end |
#telemetry_enabled ⇒ Object
Telemetry settings
21 22 23 |
# File 'lib/flagstack/configuration.rb', line 21 def telemetry_enabled @telemetry_enabled end |
#telemetry_interval ⇒ Object
Telemetry settings
21 22 23 |
# File 'lib/flagstack/configuration.rb', line 21 def telemetry_interval @telemetry_interval end |
#token ⇒ Object
Authentication
6 7 8 |
# File 'lib/flagstack/configuration.rb', line 6 def token @token end |
#url ⇒ Object
Server
9 10 11 |
# File 'lib/flagstack/configuration.rb', line 9 def url @url end |
#write_timeout ⇒ Object
HTTP settings
12 13 14 |
# File 'lib/flagstack/configuration.rb', line 12 def write_timeout @write_timeout end |
Instance Method Details
#environment_from_token ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/flagstack/configuration.rb', line 54 def environment_from_token return :unknown unless token prefix = token.split("_")[1] case prefix when "live" then :production when "test" then :staging when "dev" then :development when "personal" then :personal else :unknown end end |
#instrument(name, payload = {}, &block) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/flagstack/configuration.rb', line 46 def instrument(name, payload = {}, &block) if instrumenter instrumenter.instrument("flagstack.#{name}", payload, &block) elsif block yield payload end end |
#log(message, level: :debug) ⇒ Object
42 43 44 |
# File 'lib/flagstack/configuration.rb', line 42 def log(, level: :debug) logger&.send(level, "[Flagstack] #{message}") end |
#validate! ⇒ Object
38 39 40 |
# File 'lib/flagstack/configuration.rb', line 38 def validate! raise ConfigurationError, "Token is required. Set FLAGSTACK_TOKEN or pass token option." if token.nil? || token.empty? end |