Skip to content

Commit 19b70c2

Browse files
update
1 parent f688702 commit 19b70c2

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/AzureAppConfigurationImpl.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ type SettingSelectorCollection = {
8181
* It can either be the page etag or etag of a watched setting depending on the refresh monitoring strategy.
8282
* When a watched setting is deleted, the token value will be SHA-256 hash of `ResourceDeleted\n{previous-etag}`.
8383
*/
84-
cdnCacheConsistencyToken?: string;
84+
cdnToken?: string;
8585
}
8686

8787
export class AzureAppConfigurationImpl implements AzureAppConfiguration {
@@ -504,10 +504,10 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
504504
};
505505

506506
// If CDN is used, add etag to request header so that the pipeline policy can retrieve and append it to the request URL
507-
if (this.#isCdnUsed && selectorCollection.cdnCacheConsistencyToken) {
507+
if (this.#isCdnUsed && selectorCollection.cdnToken) {
508508
listOptions = {
509509
...listOptions,
510-
requestOptions: { customHeaders: { [ETAG_LOOKUP_HEADER]: selectorCollection.cdnCacheConsistencyToken }}
510+
requestOptions: { customHeaders: { [ETAG_LOOKUP_HEADER]: selectorCollection.cdnToken }}
511511
};
512512
}
513513
const pageEtags: string[] = [];
@@ -617,8 +617,8 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
617617
// Send a request to retrieve watched key-value since it may be either not loaded or loaded with a different selector
618618
// If CDN is used, add etag to request header so that the pipeline policy can retrieve and append it to the request URL
619619
let getOptions: GetConfigurationSettingOptions = {};
620-
if (this.#isCdnUsed && this.#kvSelectorCollection.cdnCacheConsistencyToken) {
621-
getOptions = { requestOptions: { customHeaders: { [ETAG_LOOKUP_HEADER]: this.#kvSelectorCollection.cdnCacheConsistencyToken } } };
620+
if (this.#isCdnUsed && this.#kvSelectorCollection.cdnToken) {
621+
getOptions = { requestOptions: { customHeaders: { [ETAG_LOOKUP_HEADER]: this.#kvSelectorCollection.cdnToken } } };
622622
}
623623
const response = await this.#getConfigurationSetting(sentinel, getOptions);
624624
sentinel.etag = response?.etag;
@@ -677,10 +677,10 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
677677
for (const sentinel of this.#sentinels.values()) {
678678
// if CDN is used, add etag to request header so that the pipeline policy can retrieve and append it to the request URL
679679
let getOptions: GetConfigurationSettingOptions = {};
680-
if (this.#isCdnUsed && this.#kvSelectorCollection.cdnCacheConsistencyToken) {
680+
if (this.#isCdnUsed && this.#kvSelectorCollection.cdnToken) {
681681
// if CDN is used, add etag to request header so that the pipeline policy can retrieve and append it to the request URL
682682
getOptions = {
683-
requestOptions: { customHeaders: { [ETAG_LOOKUP_HEADER]: this.#kvSelectorCollection.cdnCacheConsistencyToken ?? "" } },
683+
requestOptions: { customHeaders: { [ETAG_LOOKUP_HEADER]: this.#kvSelectorCollection.cdnToken ?? "" } },
684684
};
685685
}
686686
// send conditional request only when CDN is not used
@@ -690,10 +690,10 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
690690
(response === undefined && sentinel.etag !== undefined) // deleted
691691
) {
692692
if (response === undefined) {
693-
this.#kvSelectorCollection.cdnCacheConsistencyToken =
693+
this.#kvSelectorCollection.cdnToken =
694694
await this.#calculateResourceDeletedCacheConsistencyToken(sentinel.etag!);
695695
} else {
696-
this.#kvSelectorCollection.cdnCacheConsistencyToken = response.etag;
696+
this.#kvSelectorCollection.cdnToken = response.etag;
697697
}
698698
sentinel.etag = response?.etag; // update etag of the sentinel
699699
needRefresh = true;
@@ -750,11 +750,11 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
750750
...listOptions,
751751
pageEtags: selector.pageEtags
752752
};
753-
} else if (selectorCollection.cdnCacheConsistencyToken) {
753+
} else if (selectorCollection.cdnToken) {
754754
// If CDN is used, add etag to request header so that the pipeline policy can retrieve and append it to the request URL
755755
listOptions = {
756756
...listOptions,
757-
requestOptions: { customHeaders: { [ETAG_LOOKUP_HEADER]: selectorCollection.cdnCacheConsistencyToken } }
757+
requestOptions: { customHeaders: { [ETAG_LOOKUP_HEADER]: selectorCollection.cdnToken } }
758758
};
759759
}
760760

@@ -775,15 +775,15 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
775775
// 100 kvs will return two pages, one page with 100 items and another empty page
776776
// kv collection change will always be detected by page etag change
777777
if (this.#isCdnUsed) {
778-
selectorCollection.cdnCacheConsistencyToken = page.etag;
778+
selectorCollection.cdnToken = page.etag;
779779
}
780780
return true;
781781
}
782782
i++;
783783
}
784784
if (i !== selector.pageEtags.length) { // page removed
785785
if (this.#isCdnUsed) {
786-
selectorCollection.cdnCacheConsistencyToken = selector.pageEtags[i];
786+
selectorCollection.cdnToken = selector.pageEtags[i];
787787
}
788788
return true;
789789
}

src/load.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,15 @@ export async function loadFromCdn(
7878
): Promise<AzureAppConfiguration> {
7979
if (appConfigOptions === undefined) {
8080
appConfigOptions = {
81-
replicaDiscoveryEnabled: false // Disable replica discovery for CDN
81+
replicaDiscoveryEnabled: false // replica discovery will be enabled by default, disable it for CDN manually
8282
};
83-
} else if (appConfigOptions.replicaDiscoveryEnabled) {
83+
}
84+
if (appConfigOptions.replicaDiscoveryEnabled) {
8485
throw new ArgumentError("Replica discovery is not supported when loading from CDN.");
8586
}
87+
if (appConfigOptions.loadBalancingEnabled) {
88+
throw new ArgumentError("Load balancing is not supported when loading from CDN.");
89+
}
8690

8791
appConfigOptions.clientOptions = {
8892
...appConfigOptions.clientOptions,

0 commit comments

Comments
 (0)