cosmos-explorer/src/Utils/AutoPilotUtils.ts

43 lines
1.4 KiB
TypeScript
Raw Normal View History

import * as Constants from "../Common/Constants";
import { AutoPilotOfferSettings, Offer } from "../Contracts/DataModels";
export const manualToAutoscaleDisclaimer = `The starting autoscale max RU/s will be determined by the system, based on the current manual throughput settings and storage of your resource. After autoscale has been enabled, you can change the max RU/s. <a href="${Constants.Urls.autoscaleMigration}">Learn more</a>.`;
export const minAutoPilotThroughput = 4000;
export const autoPilotIncrementStep = 1000;
export function isValidV3AutoPilotOffer(offer: Offer): boolean {
const maxThroughput =
offer &&
offer.content &&
offer.content.offerAutopilotSettings &&
offer.content.offerAutopilotSettings.maxThroughput;
return isValidAutoPilotThroughput(maxThroughput);
}
export function isValidAutoPilotThroughput(maxThroughput: number): boolean {
if (!maxThroughput) {
return false;
}
if (maxThroughput < minAutoPilotThroughput) {
return false;
}
if (maxThroughput % 1000) {
return false;
}
return true;
}
export function getMinRUsBasedOnUserInput(throughput: number): number {
return Math.round(throughput && throughput * 0.1);
}
export function getStorageBasedOnUserInput(throughput: number): number {
return Math.round(throughput && throughput * 0.01);
}
export function getAutoPilotHeaderText(): string {
return "Throughput (autoscale)";
}