mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 15:06:55 +00:00
Reverting back to a single client for memory testing.
This commit is contained in:
parent
5d3454d973
commit
638d9c1fae
@ -138,7 +138,7 @@ enum SDKSupportedCapabilities {
|
|||||||
// Need to put in some kind of function here to recreate the CosmosClient with a new endpoint.
|
// Need to put in some kind of function here to recreate the CosmosClient with a new endpoint.
|
||||||
// changeClientEndpoint.......
|
// changeClientEndpoint.......
|
||||||
|
|
||||||
let _clients: Map<string, Cosmos.CosmosClient> = new Map();
|
// let _clients: Map<string, Cosmos.CosmosClient> = new Map();
|
||||||
|
|
||||||
let _client: Cosmos.CosmosClient;
|
let _client: Cosmos.CosmosClient;
|
||||||
|
|
||||||
@ -146,29 +146,33 @@ export function client(): Cosmos.CosmosClient {
|
|||||||
console.log(`Called primary client`);
|
console.log(`Called primary client`);
|
||||||
const currentUserContextDocumentEndpoint = userContext?.databaseAccount?.properties?.documentEndpoint;
|
const currentUserContextDocumentEndpoint = userContext?.databaseAccount?.properties?.documentEndpoint;
|
||||||
console.log(`Current selected endpoint in userContext: ${currentUserContextDocumentEndpoint}`);
|
console.log(`Current selected endpoint in userContext: ${currentUserContextDocumentEndpoint}`);
|
||||||
// let mydatabaseAccountEndpoint = "Ahhhhhhhhh";
|
let mydatabaseAccountEndpoint = "Ahhhhhhhhh";
|
||||||
// if (_client) {
|
if (_client) {
|
||||||
// _client
|
_client
|
||||||
// .getDatabaseAccount()
|
.getDatabaseAccount()
|
||||||
// .then((databaseAccount) => {
|
.then((databaseAccount) => {
|
||||||
// console.log(
|
console.log(
|
||||||
// `Current primary client endpoint contacted: ${JSON.stringify(
|
`Current primary client endpoint contacted: ${JSON.stringify(
|
||||||
// databaseAccount.diagnostics.clientSideRequestStatistics.locationEndpointsContacted,
|
databaseAccount.diagnostics.clientSideRequestStatistics.locationEndpointsContacted,
|
||||||
// )}`,
|
)}`,
|
||||||
// );
|
);
|
||||||
// mydatabaseAccountEndpoint =
|
mydatabaseAccountEndpoint =
|
||||||
// databaseAccount.diagnostics.clientSideRequestStatistics.locationEndpointsContacted[0];
|
databaseAccount.diagnostics.clientSideRequestStatistics.locationEndpointsContacted[0];
|
||||||
// })
|
})
|
||||||
// .catch((error) => {
|
.catch((error) => {
|
||||||
// console.error("Error getting database account:", error);
|
console.error("Error getting database account:", error);
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
const retrievedEndpoint = endpoint() || "https://cosmos.azure.com";
|
const retrievedEndpoint = endpoint() || "https://cosmos.azure.com";
|
||||||
|
|
||||||
if (_clients.has(retrievedEndpoint)) {
|
// if (_clients.has(retrievedEndpoint)) {
|
||||||
console.log(`Current Client List: ${JSON.stringify(_clients)}`);
|
// console.log(`Current Client List: ${JSON.stringify(_clients)}`);
|
||||||
return _clients.get(retrievedEndpoint);
|
// return _clients.get(retrievedEndpoint);
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (_client && currentUserContextDocumentEndpoint === mydatabaseAccountEndpoint) {
|
||||||
|
return _client;
|
||||||
}
|
}
|
||||||
|
|
||||||
let _defaultHeaders: Cosmos.CosmosHeaders = {};
|
let _defaultHeaders: Cosmos.CosmosHeaders = {};
|
||||||
@ -232,7 +236,11 @@ export function client(): Cosmos.CosmosClient {
|
|||||||
(options as any).plugins = plugins;
|
(options as any).plugins = plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
_clients.set(retrievedEndpoint, new Cosmos.CosmosClient(options));
|
_client = null;
|
||||||
|
_client = new Cosmos.CosmosClient(options);
|
||||||
|
return _client;
|
||||||
|
|
||||||
return _clients.get(retrievedEndpoint);
|
// _clients.set(retrievedEndpoint, new Cosmos.CosmosClient(options));
|
||||||
|
|
||||||
|
// return _clients.get(retrievedEndpoint);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user