|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | # |
4 | | -# Copyright 2019-2020, Optimizely and contributors |
| 4 | +# Copyright 2019-2020, 2022, Optimizely and contributors |
5 | 5 | # |
6 | 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
7 | 7 | # you may not use this file except in compliance with the License. |
@@ -33,7 +33,7 @@ module Optimizely |
33 | 33 | class HTTPProjectConfigManager < ProjectConfigManager |
34 | 34 | # Config manager that polls for the datafile and updated ProjectConfig based on an update interval. |
35 | 35 |
|
36 | | - attr_reader :stopped, :optimizely_config |
| 36 | + attr_reader :stopped |
37 | 37 |
|
38 | 38 | # Initialize config manager. One of sdk_key or url has to be set to be able to use. |
39 | 39 | # |
@@ -80,8 +80,8 @@ def initialize( |
80 | 80 | @last_modified = nil |
81 | 81 | @skip_json_validation = skip_json_validation |
82 | 82 | @notification_center = notification_center.is_a?(Optimizely::NotificationCenter) ? notification_center : NotificationCenter.new(@logger, @error_handler) |
| 83 | + @optimizely_config = nil |
83 | 84 | @config = datafile.nil? ? nil : DatafileProjectConfig.create(datafile, @logger, @error_handler, @skip_json_validation) |
84 | | - @optimizely_config = @config.nil? ? nil : OptimizelyConfig.new(@config).config |
85 | 85 | @mutex = Mutex.new |
86 | 86 | @resource = ConditionVariable.new |
87 | 87 | @async_scheduler = AsyncScheduler.new(method(:fetch_datafile_config), @polling_interval, auto_update, @logger) |
@@ -140,6 +140,12 @@ def config |
140 | 140 | @config |
141 | 141 | end |
142 | 142 |
|
| 143 | + def optimizely_config |
| 144 | + @optimizely_config = OptimizelyConfig.new(@config).config if @optimizely_config.nil? |
| 145 | + |
| 146 | + @optimizely_config |
| 147 | + end |
| 148 | + |
143 | 149 | private |
144 | 150 |
|
145 | 151 | def fetch_datafile_config |
@@ -209,7 +215,9 @@ def set_config(config) |
209 | 215 | end |
210 | 216 |
|
211 | 217 | @config = config |
212 | | - @optimizely_config = OptimizelyConfig.new(config).config |
| 218 | + |
| 219 | + # clearing old optimizely config so that a fresh one is generated on the next api call. |
| 220 | + @optimizely_config = nil |
213 | 221 |
|
214 | 222 | @notification_center.send_notifications(NotificationCenter::NOTIFICATION_TYPES[:OPTIMIZELY_CONFIG_UPDATE]) |
215 | 223 |
|
|
0 commit comments