-
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 51 commits
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 |
|---|---|---|
|
|
@@ -24,10 +24,11 @@ public class AzureAppConfigurationOptions | |
| private static readonly TimeSpan MaxRetryDelay = TimeSpan.FromMinutes(1); | ||
|
|
||
| private List<KeyValueWatcher> _changeWatchers = new List<KeyValueWatcher>(); | ||
| private List<KeyValueWatcher> _multiKeyWatchers = new List<KeyValueWatcher>(); | ||
| private List<KeyValueWatcher> _featureFlagWatchers = new List<KeyValueWatcher>(); | ||
| private List<IKeyValueAdapter> _adapters; | ||
| private List<Func<ConfigurationSetting, ValueTask<ConfigurationSetting>>> _mappers = new List<Func<ConfigurationSetting, ValueTask<ConfigurationSetting>>>(); | ||
| private List<KeyValueSelector> _kvSelectors = new List<KeyValueSelector>(); | ||
| private List<KeyValueSelector> _featureFlagSelectors = new List<KeyValueSelector>(); | ||
| private IConfigurationRefresher _refresher = new AzureAppConfigurationRefresher(); | ||
|
|
||
| // The following set is sorted in descending order. | ||
|
|
@@ -66,6 +67,16 @@ public class AzureAppConfigurationOptions | |
| /// </summary> | ||
avanigupta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| internal IEnumerable<KeyValueSelector> KeyValueSelectors => _kvSelectors; | ||
|
|
||
| /// <summary> | ||
| /// A collection of <see cref="KeyValueSelector"/>. | ||
avanigupta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// </summary> | ||
| internal IEnumerable<KeyValueSelector> FeatureFlagSelectors => _featureFlagSelectors; | ||
|
|
||
| /// <summary> | ||
| /// The configured options for refresh. | ||
| /// </summary> | ||
| internal AzureAppConfigurationRefreshOptions RefreshOptions { get; private set; } = new AzureAppConfigurationRefreshOptions(); | ||
|
|
||
| /// <summary> | ||
| /// A collection of <see cref="KeyValueWatcher"/>. | ||
| /// </summary> | ||
|
|
@@ -74,7 +85,7 @@ public class AzureAppConfigurationOptions | |
| /// <summary> | ||
| /// A collection of <see cref="KeyValueWatcher"/>. | ||
| /// </summary> | ||
| internal IEnumerable<KeyValueWatcher> MultiKeyWatchers => _multiKeyWatchers; | ||
| internal IEnumerable<KeyValueWatcher> FeatureFlagWatchers => _featureFlagWatchers; | ||
|
|
||
| /// <summary> | ||
| /// A collection of <see cref="IKeyValueAdapter"/>. | ||
|
|
@@ -101,6 +112,12 @@ internal IEnumerable<IKeyValueAdapter> Adapters | |
| /// <remarks>This property is used only for unit testing.</remarks> | ||
| internal IConfigurationClientManager ClientManager { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// An optional class used to process pageable results from Azure App Configuration. | ||
| /// </summary> | ||
| /// <remarks>This property is only set outside of this class if it's used for unit testing.</remarks> | ||
|
||
| internal ConfigurationSettingPageableManager PageableManager { get; set; } = new ConfigurationSettingPageableManager(); | ||
|
||
|
|
||
| /// <summary> | ||
| /// An optional timespan value to set the minimum backoff duration to a value other than the default. | ||
| /// </summary> | ||
|
|
@@ -212,7 +229,7 @@ public AzureAppConfigurationOptions SelectSnapshot(string name) | |
| /// <summary> | ||
| /// Configures options for Azure App Configuration feature flags that will be parsed and transformed into feature management configuration. | ||
| /// If no filtering is specified via the <see cref="FeatureFlagOptions"/> then all feature flags with no label are loaded. | ||
| /// All loaded feature flags will be automatically registered for refresh on an individual flag level. | ||
| /// All loaded feature flags will be automatically registered for refresh as a collection. | ||
| /// </summary> | ||
| /// <param name="configure">A callback used to configure feature flag options.</param> | ||
| public AzureAppConfigurationOptions UseFeatureFlags(Action<FeatureFlagOptions> configure = null) | ||
|
|
@@ -246,16 +263,19 @@ public AzureAppConfigurationOptions UseFeatureFlags(Action<FeatureFlagOptions> c | |
| var featureFlagFilter = featureFlagSelector.KeyFilter; | ||
| var labelFilter = featureFlagSelector.LabelFilter; | ||
|
|
||
| Select(featureFlagFilter, labelFilter); | ||
| _featureFlagSelectors.AppendUnique(new KeyValueSelector | ||
amerjusupovic marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| KeyFilter = featureFlagFilter, | ||
| LabelFilter = labelFilter | ||
| }); | ||
|
|
||
| _multiKeyWatchers.AppendUnique(new KeyValueWatcher | ||
| _featureFlagWatchers.AppendUnique(new KeyValueWatcher | ||
| { | ||
| Key = featureFlagFilter, | ||
| Label = labelFilter, | ||
| // If UseFeatureFlags is called multiple times for the same key and label filters, last refresh interval wins | ||
| RefreshInterval = options.RefreshInterval | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| return this; | ||
|
|
@@ -379,7 +399,7 @@ public AzureAppConfigurationOptions ConfigureRefresh(Action<AzureAppConfiguratio | |
| var refreshOptions = new AzureAppConfigurationRefreshOptions(); | ||
| configure?.Invoke(refreshOptions); | ||
|
|
||
| if (!refreshOptions.RefreshRegistrations.Any()) | ||
| if (!refreshOptions.RefreshRegistrations.Any() && !refreshOptions.RegisterAllEnabled) | ||
avanigupta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
avanigupta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
avanigupta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| throw new ArgumentException($"{nameof(ConfigureRefresh)}() must have at least one key-value registered for refresh."); | ||
avanigupta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
@@ -390,6 +410,8 @@ public AzureAppConfigurationOptions ConfigureRefresh(Action<AzureAppConfiguratio | |
| _changeWatchers.Add(item); | ||
| } | ||
|
|
||
| RefreshOptions = refreshOptions; | ||
avanigupta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
avanigupta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| return this; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.