Class: Flipper::Adapters::Poll
- Inherits:
-
Object
- Object
- Flipper::Adapters::Poll
- Extended by:
- Forwardable
- Includes:
- Flipper::Adapter
- Defined in:
- lib/flipper/adapters/poll.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#poller ⇒ Object
readonly
Returns the value of attribute poller.
Instance Method Summary collapse
-
#initialize(poller, adapter) ⇒ Poll
constructor
A new instance of Poll.
Methods included from Flipper::Adapter
#default_config, #export, #get_all, #get_multi, #import, included, #name, #read_only?
Constructor Details
#initialize(poller, adapter) ⇒ Poll
Returns a new instance of Poll.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/flipper/adapters/poll.rb', line 17 def initialize(poller, adapter) @adapter = adapter @poller = poller @last_synced_at = 0 # If the adapter is empty, we need to sync before starting the poller. # Yes, this will block the main thread, but that's better than thinking # nothing is enabled. if adapter.features.empty? begin @poller.sync rescue # TODO: Warn here that it's possible that no data has been synced # and flags are being evaluated without flag data being present # until a sync completes. We rescue to avoid flipper being down # causing your processes to crash. end end @poller.start end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
13 14 15 |
# File 'lib/flipper/adapters/poll.rb', line 13 def adapter @adapter end |
#poller ⇒ Object (readonly)
Returns the value of attribute poller.
13 14 15 |
# File 'lib/flipper/adapters/poll.rb', line 13 def poller @poller end |