mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 19:01:28 +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>;
|
loadStoredProcedures(): Promise<any>;
|
||||||
loadTriggers(): Promise<any>;
|
loadTriggers(): Promise<any>;
|
||||||
loadOffer(): Promise<void>;
|
loadOffer(): Promise<void>;
|
||||||
|
loadAutopilotOfferWithRetry(): Promise<DataModels.Offer>;
|
||||||
|
|
||||||
createStoredProcedureNode(data: StoredProcedureDefinition & Resource): StoredProcedure;
|
createStoredProcedureNode(data: StoredProcedureDefinition & Resource): StoredProcedure;
|
||||||
createUserDefinedFunctionNode(data: UserDefinedFunctionDefinition & Resource): UserDefinedFunction;
|
createUserDefinedFunctionNode(data: UserDefinedFunctionDefinition & Resource): UserDefinedFunction;
|
||||||
|
|||||||
@@ -532,11 +532,12 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
}
|
}
|
||||||
const updatedOffer: DataModels.Offer = await updateOffer(updateOfferParams);
|
const updatedOffer: DataModels.Offer = await updateOffer(updateOfferParams);
|
||||||
this.collection.offer(updatedOffer);
|
this.collection.offer(updatedOffer);
|
||||||
this.setState({ isScaleSaveable: false, isScaleDiscardable: false });
|
|
||||||
if (this.state.isAutoPilotSelected) {
|
if (this.state.isAutoPilotSelected) {
|
||||||
|
const autoPilotOffer = await this.collection.loadAutopilotOfferWithRetry();
|
||||||
this.setState({
|
this.setState({
|
||||||
autoPilotThroughput: updatedOffer.content.offerAutopilotSettings.maxThroughput,
|
autoPilotThroughput: autoPilotOffer.content.offerAutopilotSettings.maxThroughput,
|
||||||
autoPilotThroughputBaseline: updatedOffer.content.offerAutopilotSettings.maxThroughput
|
autoPilotThroughputBaseline: autoPilotOffer.content.offerAutopilotSettings.maxThroughput
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -544,6 +545,8 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
|
|||||||
throughputBaseline: updatedOffer.content.offerThroughput
|
throughputBaseline: updatedOffer.content.offerThroughput
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.setState({ isScaleSaveable: false, isScaleDiscardable: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.container.isRefreshingExplorer(false);
|
this.container.isRefreshingExplorer(false);
|
||||||
|
|||||||
@@ -41,8 +41,11 @@ import { userContext } from "../../UserContext";
|
|||||||
import TabsBase from "../Tabs/TabsBase";
|
import TabsBase from "../Tabs/TabsBase";
|
||||||
import { fetchPortalNotifications } from "../../Common/PortalNotifications";
|
import { fetchPortalNotifications } from "../../Common/PortalNotifications";
|
||||||
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
|
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
|
||||||
|
import promiseRetry from "p-retry";
|
||||||
|
|
||||||
export default class Collection implements ViewModels.Collection {
|
export default class Collection implements ViewModels.Collection {
|
||||||
|
private static readonly LoadOfferMaxRetries = 5;
|
||||||
|
private static readonly LoadOfferRetryAfterMilliSeconds = 5000;
|
||||||
public nodeKind: string;
|
public nodeKind: string;
|
||||||
public container: Explorer;
|
public container: Explorer;
|
||||||
public self: string;
|
public self: string;
|
||||||
@@ -1331,6 +1334,20 @@ export default class Collection implements ViewModels.Collection {
|
|||||||
return this.container.findDatabaseWithId(this.databaseId);
|
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> {
|
public async loadOffer(): Promise<void> {
|
||||||
if (!this.container.isServerlessEnabled() && !this.offer()) {
|
if (!this.container.isServerlessEnabled() && !this.offer()) {
|
||||||
this.container.isRefreshingExplorer(true);
|
this.container.isRefreshingExplorer(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user