Skip to content

Commit 1ea1d51

Browse files
committed
resolve conflicts
1 parent 1c8f00d commit 1ea1d51

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/ConfigurationClientManager.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { TokenCredential } from "@azure/identity";
77
import { AzureAppConfigurationOptions, MaxRetries, MaxRetryDelayInMs } from "./AzureAppConfigurationOptions.js";
88
import { isBrowser, isWebWorker } from "./requestTracing/utils.js";
99
import * as RequestTracing from "./requestTracing/constants.js";
10+
import { shuffleList } from "./common/utils.js";
1011

1112
const TCP_ORIGIN_KEY_NAME = "_origin._tcp";
1213
const ALT_KEY_NAME = "_alt";
@@ -143,13 +144,7 @@ export class ConfigurationClientManager {
143144
throw new Error(`Failed to build fallback clients, ${error.message}`);
144145
}
145146

146-
const srvTargetHosts = result as string[];
147-
// Shuffle the list of SRV target hosts
148-
for (let i = srvTargetHosts.length - 1; i > 0; i--) {
149-
const j = Math.floor(Math.random() * (i + 1));
150-
[srvTargetHosts[i], srvTargetHosts[j]] = [srvTargetHosts[j], srvTargetHosts[i]];
151-
}
152-
147+
const srvTargetHosts = shuffleList(result) as string[];
153148
const newDynamicClients: ConfigurationClientWrapper[] = [];
154149
for (const host of srvTargetHosts) {
155150
if (isValidEndpoint(host, this.#validDomain)) {

src/common/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ export function jsonSorter(key, value) {
2222
}
2323
return value;
2424
}
25+
26+
export function shuffleList<T>(array: T[]): T[] {
27+
for (let i = array.length - 1; i > 0; i--) {
28+
const j = Math.floor(Math.random() * (i + 1));
29+
[array[i], array[j]] = [array[j], array[i]];
30+
}
31+
return array;
32+
}

0 commit comments

Comments
 (0)