@mark1russell7/capacity 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1110 -2
- package/build/index.d.ts +858 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +1713 -0
- package/build/index.js.map +1 -0
- package/build/instance-check-Bt-SI8va.js +1732 -0
- package/build/instance-check-Bt-SI8va.js.map +1 -0
- package/build/instance-sZmVOOvz.d.ts +801 -0
- package/build/instance-sZmVOOvz.d.ts.map +1 -0
- package/build/schema.d.ts +69 -0
- package/build/schema.d.ts.map +1 -0
- package/build/schema.js +325 -0
- package/build/schema.js.map +1 -0
- package/limits/alerts-routes.line.json +78 -0
- package/limits/alerts-scale.limits.json +10 -0
- package/limits/alerts-start-gate.limits.json +1149 -0
- package/limits/alerts-start-routes-limit-home.bracket.json +543 -0
- package/limits/alerts-start-routes-limit-mid.bracket.json +464 -0
- package/limits/alerts-start-routes-limit.bracket.json +579 -0
- package/limits/alerts-tail-gate.limits.json +610 -0
- package/package.json +85 -3
- package/src/app-check.ts +477 -0
- package/src/app-metrics.ts +105 -0
- package/src/app.ts +239 -0
- package/src/check.ts +253 -0
- package/src/composition.ts +680 -0
- package/src/demand.ts +312 -0
- package/src/fit.ts +153 -0
- package/src/forms.ts +358 -0
- package/src/gate.ts +237 -0
- package/src/index.ts +143 -0
- package/src/instance-check.ts +122 -0
- package/src/instance.ts +84 -0
- package/src/knee.ts +606 -0
- package/src/law.ts +236 -0
- package/src/limit.ts +112 -0
- package/src/names.ts +19 -0
- package/src/observe.ts +74 -0
- package/src/program.ts +74 -0
- package/src/scale.ts +617 -0
- package/src/schema.ts +263 -0
- package/src/value.ts +206 -0
- package/src/workload-check.ts +130 -0
- package/src/workload.ts +88 -0
package/src/workload.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Quantity } from "@mark1russell7/quantity";
|
|
2
|
+
import type { Problem } from "./law.ts";
|
|
3
|
+
|
|
4
|
+
/** This text is the format of a workload file. */
|
|
5
|
+
export const WORKLOAD_FORMAT = "capacity-workload/1";
|
|
6
|
+
|
|
7
|
+
/** This name is the variable that gives the rate of a class. A class and a level cannot use it for a different amount. */
|
|
8
|
+
export const RATE = "rate";
|
|
9
|
+
|
|
10
|
+
/** Amounts are amounts with names. Each amount is in a canonical unit of `@mark1russell7/quantity`. */
|
|
11
|
+
export type Amounts = Readonly<Record<string, Quantity>>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A workload class is one kind of request. Its `rate` tells how many requests arrive in a unit of
|
|
15
|
+
* time, for example in `{request}/s`. Its `request` gives each variable of one request, for example
|
|
16
|
+
* the size of its body and its duration.
|
|
17
|
+
*
|
|
18
|
+
* A class is one point. Requests of two sizes are two classes, each with its own rate.
|
|
19
|
+
*
|
|
20
|
+
* The field `of` names the class of the contract of the app that the class is a point of. A class
|
|
21
|
+
* with no `of` is a point of the class of the app with its own id.
|
|
22
|
+
*/
|
|
23
|
+
export interface WorkloadClass {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly of?: string | undefined;
|
|
26
|
+
readonly rate: Quantity;
|
|
27
|
+
readonly request: Amounts;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A demand is the load that clients put on a service: its classes and its levels. A level is an
|
|
32
|
+
* amount that stays in the service and does not come with each request, for example the open
|
|
33
|
+
* connections.
|
|
34
|
+
*
|
|
35
|
+
* A demand is extensive. The rates and the levels of two demands add, and they divide between the
|
|
36
|
+
* instances of a service. The variables of one request do not.
|
|
37
|
+
*/
|
|
38
|
+
export interface Demand {
|
|
39
|
+
readonly classes: readonly WorkloadClass[];
|
|
40
|
+
readonly levels: Amounts;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A plan is a workload that a person wrote. Its `note` tells where its numbers come from. */
|
|
44
|
+
export interface PlanSource {
|
|
45
|
+
readonly kind: "plan";
|
|
46
|
+
readonly note: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A metrics source is a workload from the live metrics of an app. Its `origin` names the place of
|
|
51
|
+
* the metrics. The window goes from `from` to `to`, and each is a UTC time.
|
|
52
|
+
*/
|
|
53
|
+
export interface MetricsSource {
|
|
54
|
+
readonly kind: "metrics";
|
|
55
|
+
readonly origin: string;
|
|
56
|
+
readonly from: string;
|
|
57
|
+
readonly to: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** A workload source tells where the numbers of a workload come from: a plan or the live metrics. */
|
|
61
|
+
export type WorkloadSource = PlanSource | MetricsSource;
|
|
62
|
+
|
|
63
|
+
/** A workload is a demand with a name and a source. A workload file is this record as JSON. */
|
|
64
|
+
export interface Workload extends Demand {
|
|
65
|
+
readonly format: typeof WORKLOAD_FORMAT;
|
|
66
|
+
readonly id: string;
|
|
67
|
+
readonly title: string;
|
|
68
|
+
readonly source: WorkloadSource;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** A workload problem code names the part of a workload, or of a query, that is not correct. */
|
|
72
|
+
export type WorkloadProblemCode =
|
|
73
|
+
| "shape"
|
|
74
|
+
| "format"
|
|
75
|
+
| "id"
|
|
76
|
+
| "rate"
|
|
77
|
+
| "amount"
|
|
78
|
+
| "unit"
|
|
79
|
+
| "class"
|
|
80
|
+
| "source"
|
|
81
|
+
| "factor"
|
|
82
|
+
| "variable";
|
|
83
|
+
|
|
84
|
+
/** A workload problem tells what is not correct, and where: `path` is the path of the field in the workload. */
|
|
85
|
+
export type WorkloadProblem = Problem<WorkloadProblemCode>;
|
|
86
|
+
|
|
87
|
+
/** This demand has no class and no level. It is the zero of the sum of demands. */
|
|
88
|
+
export const NO_DEMAND: Demand = { classes: [], levels: {} };
|