mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-26 12:21:23 +00:00
Added loadOfffer with retry
This commit is contained in:
@@ -437,3 +437,8 @@ export class TerminalQueryParams {
|
||||
public static readonly SubscriptionId = "subscriptionId";
|
||||
public static readonly TerminalEndpoint = "terminalEndpoint";
|
||||
}
|
||||
|
||||
export class LoadOfferRetry {
|
||||
public static readonly MaxRetries = 5;
|
||||
public static readonly RetryAfterMilliSeconds = 5000;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1331,6 +1331,22 @@ export default class Collection implements ViewModels.Collection {
|
||||
return this.container.findDatabaseWithId(this.databaseId);
|
||||
}
|
||||
|
||||
public async loadAutopilotOfferWithRetry(): Promise<DataModels.Offer> {
|
||||
let retryCount = 0;
|
||||
while (retryCount < Constants.LoadOfferRetry.MaxRetries) {
|
||||
if (this.offer().content.offerAutopilotSettings) {
|
||||
return this.offer();
|
||||
} else {
|
||||
await new Promise(resolve => setTimeout(resolve, Constants.LoadOfferRetry.RetryAfterMilliSeconds));
|
||||
await this.loadOffer();
|
||||
}
|
||||
retryCount++;
|
||||
}
|
||||
throw new Error(
|
||||
"Max Retries for loading offer are completed. Offer does not have an offerAutopilotSettings field."
|
||||
);
|
||||
}
|
||||
|
||||
public async loadOffer(): Promise<void> {
|
||||
if (!this.container.isServerlessEnabled() && !this.offer()) {
|
||||
this.container.isRefreshingExplorer(true);
|
||||
|
||||
Reference in New Issue
Block a user