mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 10:51:30 +00:00
Compare commits
4 Commits
tsStrict/f
...
users/srna
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e8793d1b1 | ||
|
|
f41de718a0 | ||
|
|
5820afc25a | ||
|
|
6d94f18f9a |
@@ -162,6 +162,7 @@ export interface Collection extends CollectionBase {
|
||||
loadStoredProcedures(): Promise<any>;
|
||||
loadTriggers(): Promise<any>;
|
||||
loadOffer(): Promise<void>;
|
||||
loadAutopilotOfferWithRetry(): Promise<DataModels.Offer>;
|
||||
|
||||
createStoredProcedureNode(data: StoredProcedureDefinition & Resource): StoredProcedure;
|
||||
createUserDefinedFunctionNode(data: UserDefinedFunctionDefinition & Resource): UserDefinedFunction;
|
||||
|
||||
@@ -532,11 +532,12 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
||||
}
|
||||
const updatedOffer: DataModels.Offer = await updateOffer(updateOfferParams);
|
||||
this.collection.offer(updatedOffer);
|
||||
this.setState({ isScaleSaveable: false, isScaleDiscardable: false });
|
||||
|
||||
if (this.state.isAutoPilotSelected) {
|
||||
const autoPilotOffer = await this.collection.loadAutopilotOfferWithRetry();
|
||||
this.setState({
|
||||
autoPilotThroughput: updatedOffer.content.offerAutopilotSettings.maxThroughput,
|
||||
autoPilotThroughputBaseline: updatedOffer.content.offerAutopilotSettings.maxThroughput
|
||||
autoPilotThroughput: autoPilotOffer.content.offerAutopilotSettings.maxThroughput,
|
||||
autoPilotThroughputBaseline: autoPilotOffer.content.offerAutopilotSettings.maxThroughput
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
@@ -544,6 +545,8 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
||||
throughputBaseline: updatedOffer.content.offerThroughput
|
||||
});
|
||||
}
|
||||
|
||||
this.setState({ isScaleSaveable: false, isScaleDiscardable: false });
|
||||
}
|
||||
}
|
||||
this.container.isRefreshingExplorer(false);
|
||||
|
||||
@@ -41,8 +41,11 @@ import { userContext } from "../../UserContext";
|
||||
import TabsBase from "../Tabs/TabsBase";
|
||||
import { fetchPortalNotifications } from "../../Common/PortalNotifications";
|
||||
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
|
||||
import promiseRetry from "p-retry";
|
||||
|
||||
export default class Collection implements ViewModels.Collection {
|
||||
private static readonly LoadOfferMaxRetries = 5;
|
||||
private static readonly LoadOfferRetryAfterMilliSeconds = 5000;
|
||||
public nodeKind: string;
|
||||
public container: Explorer;
|
||||
public self: string;
|
||||
@@ -1331,6 +1334,20 @@ export default class Collection implements ViewModels.Collection {
|
||||
return this.container.findDatabaseWithId(this.databaseId);
|
||||
}
|
||||
|
||||
public async loadAutopilotOfferWithRetry(): Promise<DataModels.Offer> {
|
||||
let retryCount = 0;
|
||||
while (retryCount < Collection.LoadOfferMaxRetries) {
|
||||
if (this.offer().content.offerAutopilotSettings) {
|
||||
return this.offer();
|
||||
} else {
|
||||
await new Promise(resolve => setTimeout(resolve, Collection.LoadOfferRetryAfterMilliSeconds));
|
||||
await this.loadOffer();
|
||||
}
|
||||
retryCount++;
|
||||
}
|
||||
throw new Error("Max retries for loading offer are completed. Offer does not have an Autopilot settings field.");
|
||||
}
|
||||
|
||||
public async loadOffer(): Promise<void> {
|
||||
if (!this.container.isServerlessEnabled() && !this.offer()) {
|
||||
this.container.isRefreshingExplorer(true);
|
||||
|
||||
Reference in New Issue
Block a user