-
Notifications
You must be signed in to change notification settings - Fork 41
Add RegisterAll API to enable monitoring collections of key-values for refresh
#574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a6e3300
15c53fe
75a01eb
f1b07b4
25c262c
302140b
cc1bc58
28ecc05
38ba768
67ec320
9f4c1de
937e012
7e17870
f4c17ae
65de1cd
25c477b
913587e
5f84295
e18a835
d41499e
85d9909
d6ac25b
5410b5d
fc752d3
8b02c76
3ebf1e4
26d3391
aa037b6
415c577
57f5b80
7ac2cd5
bbdac93
ec9a9da
e6aadf4
a122a10
36f0b80
ba8ad5f
13db869
d39a767
113143a
ebae7c9
05ede06
e584d6c
76f369b
4e0f949
8391d74
e20546d
655ec2d
6e39cac
d9bf761
b92ae2c
81f844c
6212daa
e27dea1
78b83d3
ee36891
569656f
d049c2d
1375b28
47cd0ba
fff31b3
b9a39c4
d8ae90f
3ab8672
c2bca82
6d1cc1a
aa4829b
9afe17a
69fb9cc
1155b78
9ed77af
cd62a68
beab237
1928357
9135d42
c55aa60
0b6aecb
8b3f49a
00ac014
d318127
396fe54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ internal class AzureAppConfigurationProvider : ConfigurationProvider, IConfigura | |
| private AzureAppConfigurationOptions _options; | ||
| private Dictionary<string, ConfigurationSetting> _mappedData; | ||
| private Dictionary<KeyValueIdentifier, ConfigurationSetting> _watchedIndividualKvs = new Dictionary<KeyValueIdentifier, ConfigurationSetting>(); | ||
| private HashSet<string> _ffKeys = new HashSet<string>(); | ||
| private Dictionary<KeyValueSelector, IEnumerable<MatchConditions>> _kvEtags = new Dictionary<KeyValueSelector, IEnumerable<MatchConditions>>(); | ||
| private Dictionary<KeyValueSelector, IEnumerable<MatchConditions>> _ffEtags = new Dictionary<KeyValueSelector, IEnumerable<MatchConditions>>(); | ||
| private RequestTracingOptions _requestTracingOptions; | ||
|
|
@@ -262,6 +263,7 @@ public async Task RefreshAsync(CancellationToken cancellationToken) | |
| // Avoid instance state modification | ||
| Dictionary<KeyValueSelector, IEnumerable<MatchConditions>> ffEtags = null; | ||
| Dictionary<KeyValueSelector, IEnumerable<MatchConditions>> kvEtags = null; | ||
| HashSet<string> ffKeys = null; | ||
| Dictionary<KeyValueIdentifier, ConfigurationSetting> watchedIndividualKvs = null; | ||
| List<KeyValueChange> keyValueChanges = null; | ||
| Dictionary<string, ConfigurationSetting> data = null; | ||
|
|
@@ -273,17 +275,18 @@ public async Task RefreshAsync(CancellationToken cancellationToken) | |
|
|
||
| await ExecuteWithFailOverPolicyAsync(clients, async (client) => | ||
| { | ||
| data = null; | ||
| ffCollectionData = null; | ||
| watchedIndividualKvs = null; | ||
| kvEtags = null; | ||
| ffEtags = null; | ||
| ffKeys = null; | ||
| watchedIndividualKvs = null; | ||
| keyValueChanges = new List<KeyValueChange>(); | ||
| data = null; | ||
| ffCollectionData = null; | ||
| ffCollectionUpdated = false; | ||
| refreshAll = false; | ||
| Uri endpoint = _configClientManager.GetEndpointForClient(client); | ||
| logDebugBuilder.Clear(); | ||
| logInfoBuilder.Clear(); | ||
| Uri endpoint = _configClientManager.GetEndpointForClient(client); | ||
|
|
||
| if (_options.RegisterAllEnabled) | ||
| { | ||
|
|
@@ -315,8 +318,9 @@ await ExecuteWithFailOverPolicyAsync(clients, async (client) => | |
| // or if any key-value collection change was detected. | ||
| kvEtags = new Dictionary<KeyValueSelector, IEnumerable<MatchConditions>>(); | ||
| ffEtags = new Dictionary<KeyValueSelector, IEnumerable<MatchConditions>>(); | ||
| ffKeys = new HashSet<string>(); | ||
|
|
||
| data = await LoadSelected(client, kvEtags, ffEtags, _options.Selectors, cancellationToken).ConfigureAwait(false); | ||
| data = await LoadSelected(client, kvEtags, ffEtags, _options.Selectors, ffKeys, cancellationToken).ConfigureAwait(false); | ||
| watchedIndividualKvs = await LoadKeyValuesRegisteredForRefresh(client, data, cancellationToken).ConfigureAwait(false); | ||
| logInfoBuilder.AppendLine(LogHelper.BuildConfigurationUpdatedMessage()); | ||
| return; | ||
|
|
@@ -332,12 +336,14 @@ await ExecuteWithFailOverPolicyAsync(clients, async (client) => | |
| if (ffCollectionUpdated) | ||
| { | ||
| ffEtags = new Dictionary<KeyValueSelector, IEnumerable<MatchConditions>>(); | ||
| ffKeys = new HashSet<string>(); | ||
|
|
||
| ffCollectionData = await LoadSelected( | ||
| client, | ||
| new Dictionary<KeyValueSelector, IEnumerable<MatchConditions>>(), | ||
| ffEtags, | ||
| _options.Selectors.Where(selector => selector.IsFeatureFlagSelector), | ||
| ffKeys, | ||
| cancellationToken).ConfigureAwait(false); | ||
|
|
||
| logInfoBuilder.Append(LogHelper.BuildFeatureFlagsUpdatedMessage()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see anywhere that we logged feature flag updates as info before. Am I missing it. Also, why
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We had a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. In that case, I see for configuration we log "Configuration reloaded.", but for flags it is currently "Feature flags updated." It seems to me we should be consistent and log "Feature flags reloaded."
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, they both do a full reload so it makes sense |
||
|
|
@@ -374,6 +380,12 @@ await ExecuteWithFailOverPolicyAsync(clients, async (client) => | |
|
|
||
| if (ffCollectionUpdated) | ||
| { | ||
| // Remove all feature flag keys that are not present in the latest loading of feature flags, but were loaded previously | ||
| foreach (string key in _ffKeys.Except(ffKeys)) | ||
| { | ||
| _mappedData.Remove(key); | ||
| } | ||
|
|
||
| Dictionary<string, ConfigurationSetting> mappedFfData = await MapConfigurationSettings(ffCollectionData).ConfigureAwait(false); | ||
|
|
||
| foreach (KeyValuePair<string, ConfigurationSetting> kvp in mappedFfData) | ||
|
|
@@ -397,11 +409,13 @@ await ExecuteWithFailOverPolicyAsync(clients, async (client) => | |
|
|
||
| if (_options.Adapters.Any(adapter => adapter.NeedsRefresh()) || keyValueChanges.Any() || refreshAll || ffCollectionUpdated) | ||
| { | ||
| _watchedIndividualKvs = watchedIndividualKvs; | ||
| _watchedIndividualKvs = watchedIndividualKvs ?? _watchedIndividualKvs; | ||
|
|
||
| _ffEtags = ffEtags ?? _ffEtags; | ||
|
|
||
| _ffEtags = ffEtags; | ||
| _kvEtags = kvEtags ?? _kvEtags; | ||
|
|
||
| _kvEtags = kvEtags; | ||
| _ffKeys = ffKeys ?? _ffKeys; | ||
|
|
||
| if (logDebugBuilder.Length > 0) | ||
| { | ||
|
|
@@ -698,6 +712,7 @@ private async Task InitializeAsync(IEnumerable<ConfigurationClient> clients, Can | |
| Dictionary<KeyValueSelector, IEnumerable<MatchConditions>> kvEtags = new Dictionary<KeyValueSelector, IEnumerable<MatchConditions>>(); | ||
| Dictionary<KeyValueSelector, IEnumerable<MatchConditions>> ffEtags = new Dictionary<KeyValueSelector, IEnumerable<MatchConditions>>(); | ||
| Dictionary<KeyValueIdentifier, ConfigurationSetting> watchedIndividualKvs = null; | ||
| HashSet<string> ffKeys = new HashSet<string>(); | ||
|
|
||
| await ExecuteWithFailOverPolicyAsync( | ||
| clients, | ||
|
|
@@ -708,6 +723,7 @@ await ExecuteWithFailOverPolicyAsync( | |
| kvEtags, | ||
| ffEtags, | ||
| _options.Selectors, | ||
| ffKeys, | ||
| cancellationToken) | ||
| .ConfigureAwait(false); | ||
|
|
||
|
|
@@ -755,6 +771,7 @@ private async Task<Dictionary<string, ConfigurationSetting>> LoadSelected( | |
| Dictionary<KeyValueSelector, IEnumerable<MatchConditions>> kvEtags, | ||
| Dictionary<KeyValueSelector, IEnumerable<MatchConditions>> ffEtags, | ||
| IEnumerable<KeyValueSelector> selectors, | ||
| HashSet<string> ffKeys, | ||
| CancellationToken cancellationToken) | ||
| { | ||
| Dictionary<string, ConfigurationSetting> data = new Dictionary<string, ConfigurationSetting>(); | ||
|
|
@@ -784,6 +801,11 @@ await CallWithRequestTracing(async () => | |
| foreach (ConfigurationSetting setting in page.Values) | ||
avanigupta marked this conversation as resolved.
Show resolved
Hide resolved
avanigupta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| data[setting.Key] = setting; | ||
|
|
||
| if (loadOption.IsFeatureFlagSelector) | ||
| { | ||
| ffKeys.Add(setting.Key); | ||
| } | ||
| } | ||
|
|
||
| matchConditions.Add(new MatchConditions { IfNoneMatch = serverEtag }); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.