Class: Flagstack::Instance
- Inherits:
-
Object
- Object
- Flagstack::Instance
- Defined in:
- lib/flagstack.rb
Overview
Instance holds the configured state for a Flagstack setup
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#flipper ⇒ Object
readonly
Returns the value of attribute flipper.
-
#local_adapter ⇒ Object
readonly
Returns the value of attribute local_adapter.
-
#telemetry ⇒ Object
readonly
Returns the value of attribute telemetry.
Instance Method Summary collapse
-
#initialize(configuration) ⇒ Instance
constructor
A new instance of Instance.
- #record_telemetry(feature_key, result) ⇒ Object
- #start_poller ⇒ Object
- #start_telemetry ⇒ Object
- #stop_poller ⇒ Object
- #stop_telemetry ⇒ Object
- #sync ⇒ Object
Constructor Details
#initialize(configuration) ⇒ Instance
Returns a new instance of Instance.
245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/flagstack.rb', line 245 def initialize(configuration) @configuration = configuration @client = Client.new(configuration) @local_adapter = configuration.local_adapter || default_adapter @flipper = Flipper.new(@local_adapter, instrumenter: TelemetryInstrumenter.new(self)) @synchronizer = Synchronizer.new( client: @client, flipper: @flipper, config: @configuration ) @poller = nil @telemetry = Telemetry.new(@client, @configuration) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
243 244 245 |
# File 'lib/flagstack.rb', line 243 def client @client end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
243 244 245 |
# File 'lib/flagstack.rb', line 243 def configuration @configuration end |
#flipper ⇒ Object (readonly)
Returns the value of attribute flipper.
243 244 245 |
# File 'lib/flagstack.rb', line 243 def flipper @flipper end |
#local_adapter ⇒ Object (readonly)
Returns the value of attribute local_adapter.
243 244 245 |
# File 'lib/flagstack.rb', line 243 def local_adapter @local_adapter end |
#telemetry ⇒ Object (readonly)
Returns the value of attribute telemetry.
243 244 245 |
# File 'lib/flagstack.rb', line 243 def telemetry @telemetry end |
Instance Method Details
#record_telemetry(feature_key, result) ⇒ Object
285 286 287 |
# File 'lib/flagstack.rb', line 285 def record_telemetry(feature_key, result) @telemetry&.record(feature_key, result) end |
#start_poller ⇒ Object
263 264 265 266 267 268 269 |
# File 'lib/flagstack.rb', line 263 def start_poller return if @poller&.running? @poller = Poller.new(@synchronizer, @configuration) @poller.start @configuration.log("Started background poller (interval: #{@configuration.sync_interval}s)", level: :info) end |
#start_telemetry ⇒ Object
276 277 278 279 |
# File 'lib/flagstack.rb', line 276 def start_telemetry return unless @configuration.telemetry_enabled @telemetry.start end |
#stop_poller ⇒ Object
271 272 273 274 |
# File 'lib/flagstack.rb', line 271 def stop_poller @poller&.stop @poller = nil end |
#stop_telemetry ⇒ Object
281 282 283 |
# File 'lib/flagstack.rb', line 281 def stop_telemetry @telemetry&.stop end |
#sync ⇒ Object
259 260 261 |
# File 'lib/flagstack.rb', line 259 def sync @synchronizer.sync end |