-
Notifications
You must be signed in to change notification settings - Fork 4
Support snapshot reference #232
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
base: main
Are you sure you want to change the base?
Conversation
|
Should we handle the case that sentinel key is a snapshot reference? |
1785813 to
90d0727
Compare
| const snapshotRef: ConfigurationSetting<SnapshotReferenceValue> = parseSnapshotReference(setting); | ||
| const snapshotName = snapshotRef.value.snapshotName; | ||
| if (!snapshotName) { | ||
| throw new SnapshotReferenceError(`Invalid format for Snapshot reference setting '${setting.key}'.`); |
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.
We use InvalidOperationError if a snapshot has the wrong composition type. Can't we use it for this case as well?
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 throwing SnapshotReferenceError when composition type is wrong. This will make it consistent with how we throw KeyValueReferenceError
BTW, InvalidOperationError is not a javascript built-in error type. It is a custom error type defined by us.
Snapshot Reference
A snapshot reference is a configuration setting that references a snapshot in the same App Configuration store. When loaded, the provider resolves it and adds all key-values from that snapshot. Using snapshot references enables switching between snapshots at runtime, unlike using a snapshot selector, which requires code changes and/or restarts to switch to a new snapshot.
The content type of a snapshot reference is:
"application/json; profile=\"https://azconfig.io/mime-profiles/snapshot-ref\"; charset=utf-8";Behavior difference from .NET provider
Different from PR #689
The snapshot api design in JS provider is different from .NET provider.
In JS provider, keyvalue and feature flag are fully decoupled. The load and refresh operations for key values and feature flags are performed separatedly. The selector for key value will not load feature flags, vice versa. You must explicitly specify selectors for them.
To load key value or feature flag from snapshot, you must use a snapshot selector i.e.
SettingSelector.snapshotName. When you specify a snapshot selector for key values, even if there is any feature flag in that snapshot, the feature flag will not be loaded when loading key values. You must also specify the same snapshot selector inFeatureFlagOptions.It is a library level choice. We won't break it. So, when resolving a snapshot reference, feature flags in the snapshot will be ignored.
Note: This PR is not ready for review yet. It depends on the Azure JS SDK adding support for snapshot reference types. After that update, I’ll replace all existing helper functions with the SDK ones.