@studion/infra-code-blocks
Version:
Studion common infra components
42 lines (41 loc) • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseTaskSize = parseTaskSize;
function parseTaskSize(size) {
if (typeof size === 'string') {
const { cpu, memory } = PredefinedSize[size];
return { cpu: `${cpu}`, memory: `${memory}` };
}
return {
cpu: `${size.cpu}`,
memory: `${size.memory}`,
};
}
const CPU_1_VCPU = 1024;
const MEMORY_1GB = 1024;
const PredefinedSize = {
small: {
cpu: CPU_1_VCPU / 4, // 0.25 vCPU
memory: MEMORY_1GB / 2, // 0.5 GB memory
},
medium: {
cpu: CPU_1_VCPU / 2, // 0.5 vCPU
memory: MEMORY_1GB, // 1 GB memory
},
large: {
cpu: CPU_1_VCPU, // 1 vCPU
memory: MEMORY_1GB * 2, // 2 GB memory
},
xlarge: {
cpu: CPU_1_VCPU * 2, // 2 vCPU
memory: MEMORY_1GB * 4, // 4 GB memory
},
'2xlarge': {
cpu: CPU_1_VCPU * 4, // 4 vCPU
memory: MEMORY_1GB * 8, // 8 GB memory
},
'3xlarge': {
cpu: CPU_1_VCPU * 8, // 8 vCPU
memory: MEMORY_1GB * 16, // 16 GB memory
},
};