Class: Flagstack::Synchronizer
- Inherits:
-
Object
- Object
- Flagstack::Synchronizer
- Defined in:
- lib/flagstack/synchronizer.rb
Overview
Synchronizes features from Flagstack into the local adapter. This mirrors Flipper Cloud’s approach: remote is source of truth, local adapter is kept in sync for fast reads.
Instance Method Summary collapse
-
#initialize(client:, flipper:, config:) ⇒ Synchronizer
constructor
A new instance of Synchronizer.
-
#sync ⇒ Object
Pull features from Flagstack and write them into local adapter.
Constructor Details
#initialize(client:, flipper:, config:) ⇒ Synchronizer
Returns a new instance of Synchronizer.
6 7 8 9 10 |
# File 'lib/flagstack/synchronizer.rb', line 6 def initialize(client:, flipper:, config:) @client = client @flipper = flipper @config = config end |
Instance Method Details
#sync ⇒ Object
Pull features from Flagstack and write them into local adapter
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/flagstack/synchronizer.rb', line 13 def sync @config.log("Synchronizing features from Flagstack", level: :debug) data = @client.sync return false unless data && data["features"] features = data["features"] @config.log("Received #{features.size} features from Flagstack", level: :debug) features.each do |feature_data| sync_feature(feature_data) end @config.log("Synchronized #{features.size} features to local adapter", level: :info) true rescue => e @config.log("Sync failed: #{e.}", level: :error) false end |