-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
28 lines (27 loc) · 1.01 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { generate } from './src/generate_request_data'
import * as calc from './src/calculator'
import { Component, ComputeNode, Puller, Interval } from './module'
export function calculate(
pullers: Puller[],
units: number,
components: Component[],
node: ComputeNode,
failedRequestPenalty: number,
): Interval[] {
return generate(pullers, units)
.map(calc.putComponentsIntoIntervals(components))
.map(calc.putNodesIntoIntervals(node))
.map(calc.calculateResourceNeededForRequestsInterval)
.map(calc.calculateReplicasNeededForInterval)
.map(calc.calculateResourceNeededForInterval)
.map(calc.calculateDesiredResourceForInterval)
.map(calc.calculateNodesNeededForInterval)
.map(calc.calculateNodesDesiredForInterval)
.map(calc.calculateReadyNodes)
.map(calc.calculatePendingPods)
.map(calc.calculateReadyPods)
.map(calc.calculateReadyRequestCapacity)
.map(calc.calculateFailedRequests)
.map(calc.calculateCosts)
.map(calc.calculatePenalties(failedRequestPenalty))
}