-
Notifications
You must be signed in to change notification settings - Fork 5
PageETage based refresh support #23
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 all commits
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 |
|---|---|---|
|
|
@@ -35,19 +35,25 @@ import ( | |
|
|
||
| // An AzureAppConfiguration is a configuration provider that stores and manages settings sourced from Azure App Configuration. | ||
| type AzureAppConfiguration struct { | ||
| // Settings loaded from Azure App Configuration | ||
| keyValues map[string]any | ||
|
|
||
| // Settings configured from Options | ||
| kvSelectors []Selector | ||
| trimPrefixes []string | ||
| watchedSettings []WatchedSetting | ||
|
|
||
| // Settings used for refresh scenarios | ||
| sentinelETags map[WatchedSetting]*azcore.ETag | ||
| watchAll bool | ||
| pageETags map[Selector][]*azcore.ETag | ||
| keyVaultRefs map[string]string // unversioned Key Vault references | ||
| kvRefreshTimer refresh.Condition | ||
| secretRefreshTimer refresh.Condition | ||
| onRefreshSuccess []func() | ||
| tracingOptions tracing.Options | ||
|
|
||
| // Clients talking to Azure App Configuration/Azure Key Vault service | ||
| clientManager *configurationClientManager | ||
| resolver *keyVaultReferenceResolver | ||
|
|
||
|
|
@@ -99,6 +105,10 @@ func Load(ctx context.Context, authentication AuthenticationOptions, options *Op | |
| azappcfg.kvRefreshTimer = refresh.NewTimer(options.RefreshOptions.Interval) | ||
| azappcfg.watchedSettings = normalizedWatchedSettings(options.RefreshOptions.WatchedSettings) | ||
| azappcfg.sentinelETags = make(map[WatchedSetting]*azcore.ETag) | ||
| azappcfg.pageETags = make(map[Selector][]*azcore.ETag) | ||
| if len(options.RefreshOptions.WatchedSettings) == 0 { | ||
RichardChen820 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| azappcfg.watchAll = true | ||
| } | ||
| } | ||
|
|
||
| if options.KeyVaultOptions.RefreshOptions.Enabled { | ||
|
|
@@ -355,6 +365,7 @@ func (azappcfg *AzureAppConfiguration) loadKeyValues(ctx context.Context, settin | |
| maps.Copy(kvSettings, secrets) | ||
| azappcfg.keyValues = kvSettings | ||
| azappcfg.keyVaultRefs = getUnversionedKeyVaultRefs(keyVaultRefs) | ||
| azappcfg.pageETags = settingsResponse.pageETags | ||
|
|
||
| return nil | ||
| } | ||
|
|
@@ -407,7 +418,7 @@ func (azappcfg *AzureAppConfiguration) refreshKeyValues(ctx context.Context, ref | |
| // Check if any ETags have changed | ||
| eTagChanged, err := refreshClient.monitor.checkIfETagChanged(ctx) | ||
| if err != nil { | ||
| return false, fmt.Errorf("failed to check if watched settings have changed: %w", err) | ||
| return false, fmt.Errorf("failed to check if key value settings have changed: %w", err) | ||
|
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. feels that the previous error message is just fine, "watched settings" is also accurate for "watch all" scenario.
Member
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 have |
||
| } | ||
|
|
||
| if !eTagChanged { | ||
|
|
@@ -572,17 +583,28 @@ func normalizedWatchedSettings(s []WatchedSetting) []WatchedSetting { | |
| } | ||
|
|
||
| func (azappcfg *AzureAppConfiguration) newKeyValueRefreshClient() refreshClient { | ||
| return refreshClient{ | ||
| loader: &selectorSettingsClient{ | ||
| selectors: azappcfg.kvSelectors, | ||
| var monitor eTagsClient | ||
| if azappcfg.watchAll { | ||
| monitor = &pageETagsClient{ | ||
| client: azappcfg.clientManager.staticClient.client, | ||
| tracingOptions: azappcfg.tracingOptions, | ||
| pageETags: azappcfg.pageETags, | ||
| } | ||
| } else { | ||
| monitor = &watchedSettingClient{ | ||
| client: azappcfg.clientManager.staticClient.client, | ||
| tracingOptions: azappcfg.tracingOptions, | ||
| }, | ||
| monitor: &watchedSettingClient{ | ||
| eTags: azappcfg.sentinelETags, | ||
| } | ||
| } | ||
|
|
||
| return refreshClient{ | ||
| loader: &selectorSettingsClient{ | ||
| selectors: azappcfg.kvSelectors, | ||
| client: azappcfg.clientManager.staticClient.client, | ||
| tracingOptions: azappcfg.tracingOptions, | ||
| }, | ||
| monitor: monitor, | ||
| sentinels: &watchedSettingClient{ | ||
| watchedSettings: azappcfg.watchedSettings, | ||
| client: azappcfg.clientManager.staticClient.client, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are blank lines between some fields, which seem to be used to categorize the fields, but I didn't get the underlying rule, it's likely just random to me for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the top,
keyValuesandfeastureFlags(in the future) are settings from store. In the middle, options configured by user. Next, cache for refresh scenario.clientManagerandresolverare objects talk to service.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding some comments for them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.