@mark1russell7/capacity 0.0.0-bootstrap.0 → 0.1.0
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 +1107 -1
- 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-0n6WhJzF.d.ts +782 -0
- package/build/instance-0n6WhJzF.d.ts.map +1 -0
- package/build/instance-check-CAuD9L4Z.js +1711 -0
- package/build/instance-check-CAuD9L4Z.js.map +1 -0
- package/build/schema.d.ts +69 -0
- package/build/schema.d.ts.map +1 -0
- package/build/schema.js +315 -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 +79 -4
- package/src/app-check.ts +477 -0
- package/src/app-metrics.ts +105 -0
- package/src/app.ts +239 -0
- package/src/check.ts +228 -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 +142 -0
- package/src/instance-check.ts +122 -0
- package/src/instance.ts +84 -0
- package/src/knee.ts +606 -0
- package/src/law.ts +215 -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 +260 -0
- package/src/value.ts +206 -0
- package/src/workload-check.ts +130 -0
- package/src/workload.ts +88 -0
package/build/schema.js
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { B as WORKLOAD_FORMAT, E as checkApp, F as checkWorkload, G as checkLaw, K as LAW_DOMAINS, N as APP_FORMAT, P as APP_LINE_KINDS, l as COMPOSITION_FORMAT, n as checkLimits, nt as LAW_FORMAT, o as INSTANCE_FORMAT, s as LIMITS_FORMAT, t as checkInstance, u as checkComposition } from "./instance-check-CAuD9L4Z.js";
|
|
2
|
+
import { parse } from "@mark1russell7/vex";
|
|
3
|
+
import { err, ok } from "@mark1russell7/optional";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
// src/schema.ts
|
|
6
|
+
/** This function tells if a value from JSON is a Vex expression. */
|
|
7
|
+
const isProgram = (value) => {
|
|
8
|
+
const text = JSON.stringify(value);
|
|
9
|
+
return text !== void 0 && parse(text, LAW_DOMAINS).ok;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* This function makes the reader of a record. The reader examines the shape of the data with the
|
|
13
|
+
* schema, then it examines the meaning with `check`. It gives the record, or each problem.
|
|
14
|
+
*/
|
|
15
|
+
const reader = (schema, check) => (data) => {
|
|
16
|
+
const shape = schema.safeParse(data);
|
|
17
|
+
if (!shape.success) return err(shape.error.issues.map((issue) => ({
|
|
18
|
+
code: "shape",
|
|
19
|
+
path: issue.path.join("."),
|
|
20
|
+
message: issue.message
|
|
21
|
+
})));
|
|
22
|
+
const problems = check(shape.data);
|
|
23
|
+
return problems.length > 0 ? err(problems) : ok(shape.data);
|
|
24
|
+
};
|
|
25
|
+
const fitErrorSchema = z.strictObject({
|
|
26
|
+
mae: z.number(),
|
|
27
|
+
rmse: z.number()
|
|
28
|
+
});
|
|
29
|
+
const runSchema = z.strictObject({
|
|
30
|
+
url: z.string(),
|
|
31
|
+
commit: z.string(),
|
|
32
|
+
date: z.string()
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* This schema accepts the shape of a law file: each field with its type, and no other field. It
|
|
36
|
+
* does not examine what the fields mean. The function `checkLaw` does that.
|
|
37
|
+
*/
|
|
38
|
+
const lawSchema = z.strictObject({
|
|
39
|
+
format: z.literal(LAW_FORMAT),
|
|
40
|
+
id: z.string(),
|
|
41
|
+
title: z.string(),
|
|
42
|
+
subject: z.string(),
|
|
43
|
+
measure: z.strictObject({
|
|
44
|
+
id: z.string(),
|
|
45
|
+
unit: z.string()
|
|
46
|
+
}),
|
|
47
|
+
variables: z.array(z.strictObject({
|
|
48
|
+
id: z.string(),
|
|
49
|
+
unit: z.string(),
|
|
50
|
+
min: z.number(),
|
|
51
|
+
max: z.number(),
|
|
52
|
+
scale: z.enum(["linear", "log"])
|
|
53
|
+
})),
|
|
54
|
+
conditions: z.record(z.string(), z.union([
|
|
55
|
+
z.string(),
|
|
56
|
+
z.number(),
|
|
57
|
+
z.boolean(),
|
|
58
|
+
z.strictObject({
|
|
59
|
+
value: z.number(),
|
|
60
|
+
unit: z.string()
|
|
61
|
+
})
|
|
62
|
+
])),
|
|
63
|
+
form: z.strictObject({
|
|
64
|
+
id: z.string(),
|
|
65
|
+
program: z.custom(isProgram, "The program is not a Vex expression.")
|
|
66
|
+
}),
|
|
67
|
+
constants: z.array(z.strictObject({
|
|
68
|
+
id: z.string(),
|
|
69
|
+
value: z.number()
|
|
70
|
+
})),
|
|
71
|
+
replicates: z.array(z.array(z.number())),
|
|
72
|
+
fit: z.strictObject({
|
|
73
|
+
method: z.string(),
|
|
74
|
+
residual: z.enum(["absolute", "relative"]),
|
|
75
|
+
residuals: z.array(z.number()),
|
|
76
|
+
losers: z.array(z.strictObject({
|
|
77
|
+
form: z.string(),
|
|
78
|
+
error: fitErrorSchema
|
|
79
|
+
}))
|
|
80
|
+
}),
|
|
81
|
+
points: z.array(z.strictObject({
|
|
82
|
+
load: z.record(z.string(), z.number()),
|
|
83
|
+
value: z.number(),
|
|
84
|
+
run: z.number(),
|
|
85
|
+
job: z.string()
|
|
86
|
+
})).exactOptional(),
|
|
87
|
+
evidence: z.strictObject({ runs: z.array(runSchema) }),
|
|
88
|
+
noise: z.strictObject({
|
|
89
|
+
floor: z.number(),
|
|
90
|
+
cpu: z.string(),
|
|
91
|
+
runs: z.array(runSchema)
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
/**
|
|
95
|
+
* This function reads a law from the data of a law file. It gives the law when the data has the
|
|
96
|
+
* shape of a law and `checkLaw` finds no problem. If not, it gives each problem.
|
|
97
|
+
*/
|
|
98
|
+
const readLaw = reader(lawSchema, checkLaw);
|
|
99
|
+
const factorSchema = z.number().optional();
|
|
100
|
+
/**
|
|
101
|
+
* This schema accepts the shape of a composition file: each field with its type, and no other
|
|
102
|
+
* field. It does not examine what the fields mean. The function `checkComposition` does that.
|
|
103
|
+
*/
|
|
104
|
+
const compositionSchema = z.strictObject({
|
|
105
|
+
format: z.literal(COMPOSITION_FORMAT),
|
|
106
|
+
id: z.string(),
|
|
107
|
+
title: z.string(),
|
|
108
|
+
subject: z.string(),
|
|
109
|
+
measure: z.strictObject({
|
|
110
|
+
id: z.string(),
|
|
111
|
+
unit: z.string()
|
|
112
|
+
}),
|
|
113
|
+
terms: z.array(z.union([z.strictObject({
|
|
114
|
+
law: z.string(),
|
|
115
|
+
over: z.union([
|
|
116
|
+
z.literal("instance"),
|
|
117
|
+
z.literal("each"),
|
|
118
|
+
z.array(z.string())
|
|
119
|
+
]),
|
|
120
|
+
load: z.enum(["class", "total"]).optional(),
|
|
121
|
+
factor: factorSchema,
|
|
122
|
+
base: z.lazy(() => amountsSchema).optional()
|
|
123
|
+
}), z.strictObject({
|
|
124
|
+
composition: z.string(),
|
|
125
|
+
factor: factorSchema
|
|
126
|
+
})]))
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* This function reads a composition from the data of a composition file. It gives the composition
|
|
130
|
+
* when the data has the shape of one and `checkComposition` finds no problem. If not, it gives each
|
|
131
|
+
* problem.
|
|
132
|
+
*/
|
|
133
|
+
const readComposition = reader(compositionSchema, checkComposition);
|
|
134
|
+
const amountSchema = z.strictObject({
|
|
135
|
+
value: z.number(),
|
|
136
|
+
unit: z.string()
|
|
137
|
+
});
|
|
138
|
+
const amountsSchema = z.record(z.string(), amountSchema);
|
|
139
|
+
/**
|
|
140
|
+
* This schema accepts the shape of a workload file: each field with its type, and no other field.
|
|
141
|
+
* It does not examine what the fields mean. The function `checkWorkload` does that.
|
|
142
|
+
*/
|
|
143
|
+
const workloadSchema = z.strictObject({
|
|
144
|
+
format: z.literal(WORKLOAD_FORMAT),
|
|
145
|
+
id: z.string(),
|
|
146
|
+
title: z.string(),
|
|
147
|
+
classes: z.array(z.strictObject({
|
|
148
|
+
id: z.string(),
|
|
149
|
+
of: z.string().optional(),
|
|
150
|
+
rate: amountSchema,
|
|
151
|
+
request: amountsSchema
|
|
152
|
+
})),
|
|
153
|
+
levels: amountsSchema,
|
|
154
|
+
source: z.discriminatedUnion("kind", [z.strictObject({
|
|
155
|
+
kind: z.literal("plan"),
|
|
156
|
+
note: z.string()
|
|
157
|
+
}), z.strictObject({
|
|
158
|
+
kind: z.literal("metrics"),
|
|
159
|
+
origin: z.string(),
|
|
160
|
+
from: z.string(),
|
|
161
|
+
to: z.string()
|
|
162
|
+
})])
|
|
163
|
+
});
|
|
164
|
+
/**
|
|
165
|
+
* This function reads a workload from the data of a workload file. It gives the workload when the
|
|
166
|
+
* data has the shape of a workload and `checkWorkload` finds no problem. If not, it gives each
|
|
167
|
+
* problem.
|
|
168
|
+
*/
|
|
169
|
+
const readWorkload = reader(workloadSchema, checkWorkload);
|
|
170
|
+
/**
|
|
171
|
+
* This schema accepts the shape of an instance file: each field with its type, and no other field.
|
|
172
|
+
* It does not examine what the fields mean. The function `checkInstance` does that.
|
|
173
|
+
*/
|
|
174
|
+
const instanceSchema = z.strictObject({
|
|
175
|
+
format: z.literal(INSTANCE_FORMAT),
|
|
176
|
+
id: z.string(),
|
|
177
|
+
title: z.string(),
|
|
178
|
+
resources: amountsSchema
|
|
179
|
+
});
|
|
180
|
+
/**
|
|
181
|
+
* This function reads an instance type from the data of an instance file. It gives the instance
|
|
182
|
+
* type when the data has the shape of one and `checkInstance` finds no problem. If not, it gives
|
|
183
|
+
* each problem.
|
|
184
|
+
*/
|
|
185
|
+
const readInstance = reader(instanceSchema, checkInstance);
|
|
186
|
+
/** This schema accepts the shape of one limit: each field with its type, and no other field. */
|
|
187
|
+
const limitSchema = z.strictObject({
|
|
188
|
+
id: z.string(),
|
|
189
|
+
measure: z.string(),
|
|
190
|
+
ceiling: z.discriminatedUnion("kind", [z.strictObject({
|
|
191
|
+
kind: z.literal("amount"),
|
|
192
|
+
amount: amountSchema
|
|
193
|
+
}), z.strictObject({
|
|
194
|
+
kind: z.literal("resource"),
|
|
195
|
+
resource: z.string()
|
|
196
|
+
})]),
|
|
197
|
+
headroom: z.number()
|
|
198
|
+
});
|
|
199
|
+
/**
|
|
200
|
+
* This schema accepts the shape of a limits file: each field with its type, and no other field.
|
|
201
|
+
* It does not examine what the fields mean. The function `checkLimits` does that.
|
|
202
|
+
*/
|
|
203
|
+
const limitsSchema = z.strictObject({
|
|
204
|
+
format: z.literal(LIMITS_FORMAT),
|
|
205
|
+
id: z.string(),
|
|
206
|
+
title: z.string(),
|
|
207
|
+
limits: z.array(limitSchema)
|
|
208
|
+
});
|
|
209
|
+
/**
|
|
210
|
+
* This function reads a limit set from the data of a limits file. It gives the limit set when the
|
|
211
|
+
* data has the shape of one and `checkLimits` finds no problem. If not, it gives each problem.
|
|
212
|
+
*/
|
|
213
|
+
const readLimits = reader(limitsSchema, checkLimits);
|
|
214
|
+
const scaleSchema = z.enum(["linear", "log"]);
|
|
215
|
+
const rangeFields = {
|
|
216
|
+
unit: z.string(),
|
|
217
|
+
min: z.number(),
|
|
218
|
+
max: z.number(),
|
|
219
|
+
scale: scaleSchema
|
|
220
|
+
};
|
|
221
|
+
const commandFields = {
|
|
222
|
+
argv: z.array(z.string()),
|
|
223
|
+
cwd: z.string(),
|
|
224
|
+
env: z.record(z.string(), z.string())
|
|
225
|
+
};
|
|
226
|
+
const commandSchema = z.strictObject(commandFields);
|
|
227
|
+
const processSchema = z.strictObject({
|
|
228
|
+
...commandFields,
|
|
229
|
+
ready: z.discriminatedUnion("kind", [z.strictObject({
|
|
230
|
+
kind: z.literal("line"),
|
|
231
|
+
text: z.string()
|
|
232
|
+
}), z.strictObject({
|
|
233
|
+
kind: z.literal("http"),
|
|
234
|
+
path: z.string()
|
|
235
|
+
})])
|
|
236
|
+
});
|
|
237
|
+
/**
|
|
238
|
+
* This schema accepts the shape of the contract file of an app: each field with its type, and no other
|
|
239
|
+
* field. It does not examine what the fields mean. The function `checkApp` does that.
|
|
240
|
+
*/
|
|
241
|
+
const appSchema = z.strictObject({
|
|
242
|
+
format: z.literal(APP_FORMAT),
|
|
243
|
+
id: z.string(),
|
|
244
|
+
title: z.string(),
|
|
245
|
+
repository: z.string(),
|
|
246
|
+
variables: z.array(z.strictObject({
|
|
247
|
+
id: z.string(),
|
|
248
|
+
title: z.string(),
|
|
249
|
+
kind: z.enum([
|
|
250
|
+
"request",
|
|
251
|
+
"level",
|
|
252
|
+
"store",
|
|
253
|
+
"run"
|
|
254
|
+
]),
|
|
255
|
+
...rangeFields
|
|
256
|
+
})),
|
|
257
|
+
classes: z.array(z.strictObject({
|
|
258
|
+
id: z.string(),
|
|
259
|
+
title: z.string(),
|
|
260
|
+
rate: z.strictObject(rangeFields),
|
|
261
|
+
request: z.array(z.string()),
|
|
262
|
+
entry: z.discriminatedUnion("kind", [z.strictObject({
|
|
263
|
+
kind: z.literal("http"),
|
|
264
|
+
method: z.enum([
|
|
265
|
+
"GET",
|
|
266
|
+
"POST",
|
|
267
|
+
"PUT",
|
|
268
|
+
"PATCH",
|
|
269
|
+
"DELETE"
|
|
270
|
+
]),
|
|
271
|
+
path: z.string(),
|
|
272
|
+
body: z.string().optional()
|
|
273
|
+
}), z.strictObject({
|
|
274
|
+
kind: z.literal("service"),
|
|
275
|
+
service: z.string()
|
|
276
|
+
})])
|
|
277
|
+
})),
|
|
278
|
+
start: z.strictObject({
|
|
279
|
+
install: commandSchema.optional(),
|
|
280
|
+
check: commandSchema.optional(),
|
|
281
|
+
seed: commandSchema.optional(),
|
|
282
|
+
run: processSchema.extend({ lines: z.array(z.strictObject({
|
|
283
|
+
kind: z.enum(APP_LINE_KINDS),
|
|
284
|
+
ev: z.string(),
|
|
285
|
+
title: z.string()
|
|
286
|
+
})).optional() })
|
|
287
|
+
}),
|
|
288
|
+
services: z.array(z.strictObject({
|
|
289
|
+
id: z.string(),
|
|
290
|
+
title: z.string(),
|
|
291
|
+
fake: processSchema
|
|
292
|
+
})),
|
|
293
|
+
metrics: z.array(z.strictObject({
|
|
294
|
+
id: z.string(),
|
|
295
|
+
kind: z.enum(["counter", "gauge"]),
|
|
296
|
+
unit: z.string(),
|
|
297
|
+
of: z.union([
|
|
298
|
+
z.strictObject({ rate: z.string() }),
|
|
299
|
+
z.strictObject({ level: z.string() }),
|
|
300
|
+
z.strictObject({
|
|
301
|
+
total: z.string(),
|
|
302
|
+
class: z.string()
|
|
303
|
+
}),
|
|
304
|
+
z.strictObject({ measure: z.string() })
|
|
305
|
+
])
|
|
306
|
+
}))
|
|
307
|
+
});
|
|
308
|
+
/**
|
|
309
|
+
* This function reads the contract of an app from the data of a contract file. It gives the contract when
|
|
310
|
+
* the data has the shape of one and `checkApp` finds no problem. If not, it gives each problem.
|
|
311
|
+
*/
|
|
312
|
+
const readApp = reader(appSchema, checkApp);
|
|
313
|
+
export { appSchema, compositionSchema, instanceSchema, lawSchema, limitSchema, limitsSchema, readApp, readComposition, readInstance, readLaw, readLimits, readWorkload, workloadSchema };
|
|
314
|
+
|
|
315
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../src/schema.ts"],"sourcesContent":["import { err, ok, type Result } from \"@mark1russell7/optional\";\nimport { parse, type Expr } from \"@mark1russell7/vex\";\nimport { z } from \"zod\";\nimport { checkApp } from \"./app-check.ts\";\nimport { APP_FORMAT, APP_LINE_KINDS, type AppContract, type AppProblem } from \"./app.ts\";\nimport { checkLaw } from \"./check.ts\";\nimport { COMPOSITION_FORMAT, checkComposition, type Composition, type CompositionProblem } from \"./composition.ts\";\nimport { checkInstance, checkLimits } from \"./instance-check.ts\";\nimport {\n INSTANCE_FORMAT,\n LIMITS_FORMAT,\n type InstanceProblem,\n type InstanceType,\n type Limit,\n type LimitProblem,\n type LimitSet,\n} from \"./instance.ts\";\nimport { LAW_FORMAT, type Law, type LawProblem, type Problem } from \"./law.ts\";\nimport { LAW_DOMAINS } from \"./program.ts\";\nimport { checkWorkload } from \"./workload-check.ts\";\nimport { WORKLOAD_FORMAT, type Workload, type WorkloadProblem } from \"./workload.ts\";\n\n/** This function tells if a value from JSON is a Vex expression. */\nconst isProgram = (value: unknown): boolean => {\n const text = JSON.stringify(value);\n return text !== undefined && parse(text, LAW_DOMAINS).ok;\n};\n\n/**\n * This function makes the reader of a record. The reader examines the shape of the data with the\n * schema, then it examines the meaning with `check`. It gives the record, or each problem.\n */\nconst reader =\n <T, Code extends string>(schema: z.ZodType<T>, check: (record: T) => readonly Problem<Code>[]) =>\n (data: unknown): Result<T, readonly Problem<Code | \"shape\">[]> => {\n const shape = schema.safeParse(data);\n if (!shape.success) {\n return err(shape.error.issues.map((issue) => ({ code: \"shape\", path: issue.path.join(\".\"), message: issue.message })));\n }\n const problems = check(shape.data);\n return problems.length > 0 ? err(problems) : ok(shape.data);\n };\n\nconst fitErrorSchema = z.strictObject({ mae: z.number(), rmse: z.number() });\n\nconst runSchema = z.strictObject({ url: z.string(), commit: z.string(), date: z.string() });\n\n/**\n * This schema accepts the shape of a law file: each field with its type, and no other field. It\n * does not examine what the fields mean. The function `checkLaw` does that.\n */\nexport const lawSchema: z.ZodType<Law> = z.strictObject({\n format: z.literal(LAW_FORMAT),\n id: z.string(),\n title: z.string(),\n subject: z.string(),\n measure: z.strictObject({ id: z.string(), unit: z.string() }),\n variables: z.array(\n z.strictObject({ id: z.string(), unit: z.string(), min: z.number(), max: z.number(), scale: z.enum([\"linear\", \"log\"]) }),\n ),\n conditions: z.record(\n z.string(),\n z.union([z.string(), z.number(), z.boolean(), z.strictObject({ value: z.number(), unit: z.string() })]),\n ),\n form: z.strictObject({ id: z.string(), program: z.custom<Expr>(isProgram, \"The program is not a Vex expression.\") }),\n constants: z.array(z.strictObject({ id: z.string(), value: z.number() })),\n replicates: z.array(z.array(z.number())),\n fit: z.strictObject({\n method: z.string(),\n residual: z.enum([\"absolute\", \"relative\"]),\n residuals: z.array(z.number()),\n losers: z.array(z.strictObject({ form: z.string(), error: fitErrorSchema })),\n }),\n points: z.array(z.strictObject({ load: z.record(z.string(), z.number()), value: z.number(), run: z.number(), job: z.string() })).exactOptional(),\n evidence: z.strictObject({ runs: z.array(runSchema) }),\n noise: z.strictObject({ floor: z.number(), cpu: z.string(), runs: z.array(runSchema) }),\n});\n\n/**\n * This function reads a law from the data of a law file. It gives the law when the data has the\n * shape of a law and `checkLaw` finds no problem. If not, it gives each problem.\n */\nexport const readLaw: (data: unknown) => Result<Law, readonly LawProblem[]> = reader(lawSchema, checkLaw);\n\nconst factorSchema = z.number().optional();\n\n/**\n * This schema accepts the shape of a composition file: each field with its type, and no other\n * field. It does not examine what the fields mean. The function `checkComposition` does that.\n */\nexport const compositionSchema: z.ZodType<Composition> = z.strictObject({\n format: z.literal(COMPOSITION_FORMAT),\n id: z.string(),\n title: z.string(),\n subject: z.string(),\n measure: z.strictObject({ id: z.string(), unit: z.string() }),\n terms: z.array(\n z.union([\n z.strictObject({\n law: z.string(),\n over: z.union([z.literal(\"instance\"), z.literal(\"each\"), z.array(z.string())]),\n load: z.enum([\"class\", \"total\"]).optional(),\n factor: factorSchema,\n base: z.lazy(() => amountsSchema).optional(),\n }),\n z.strictObject({ composition: z.string(), factor: factorSchema }),\n ]),\n ),\n});\n\n/**\n * This function reads a composition from the data of a composition file. It gives the composition\n * when the data has the shape of one and `checkComposition` finds no problem. If not, it gives each\n * problem.\n */\nexport const readComposition: (data: unknown) => Result<Composition, readonly CompositionProblem[]> = reader(\n compositionSchema,\n checkComposition,\n);\n\nconst amountSchema = z.strictObject({ value: z.number(), unit: z.string() });\nconst amountsSchema = z.record(z.string(), amountSchema);\n\n/**\n * This schema accepts the shape of a workload file: each field with its type, and no other field.\n * It does not examine what the fields mean. The function `checkWorkload` does that.\n */\nexport const workloadSchema: z.ZodType<Workload> = z.strictObject({\n format: z.literal(WORKLOAD_FORMAT),\n id: z.string(),\n title: z.string(),\n classes: z.array(z.strictObject({ id: z.string(), of: z.string().optional(), rate: amountSchema, request: amountsSchema })),\n levels: amountsSchema,\n source: z.discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"plan\"), note: z.string() }),\n z.strictObject({ kind: z.literal(\"metrics\"), origin: z.string(), from: z.string(), to: z.string() }),\n ]),\n});\n\n/**\n * This function reads a workload from the data of a workload file. It gives the workload when the\n * data has the shape of a workload and `checkWorkload` finds no problem. If not, it gives each\n * problem.\n */\nexport const readWorkload: (data: unknown) => Result<Workload, readonly WorkloadProblem[]> = reader(workloadSchema, checkWorkload);\n\n/**\n * This schema accepts the shape of an instance file: each field with its type, and no other field.\n * It does not examine what the fields mean. The function `checkInstance` does that.\n */\nexport const instanceSchema: z.ZodType<InstanceType> = z.strictObject({\n format: z.literal(INSTANCE_FORMAT),\n id: z.string(),\n title: z.string(),\n resources: amountsSchema,\n});\n\n/**\n * This function reads an instance type from the data of an instance file. It gives the instance\n * type when the data has the shape of one and `checkInstance` finds no problem. If not, it gives\n * each problem.\n */\nexport const readInstance: (data: unknown) => Result<InstanceType, readonly InstanceProblem[]> = reader(instanceSchema, checkInstance);\n\n/** This schema accepts the shape of one limit: each field with its type, and no other field. */\nexport const limitSchema: z.ZodType<Limit> = z.strictObject({\n id: z.string(),\n measure: z.string(),\n ceiling: z.discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"amount\"), amount: amountSchema }),\n z.strictObject({ kind: z.literal(\"resource\"), resource: z.string() }),\n ]),\n headroom: z.number(),\n});\n\n/**\n * This schema accepts the shape of a limits file: each field with its type, and no other field.\n * It does not examine what the fields mean. The function `checkLimits` does that.\n */\nexport const limitsSchema: z.ZodType<LimitSet> = z.strictObject({\n format: z.literal(LIMITS_FORMAT),\n id: z.string(),\n title: z.string(),\n limits: z.array(limitSchema),\n});\n\n/**\n * This function reads a limit set from the data of a limits file. It gives the limit set when the\n * data has the shape of one and `checkLimits` finds no problem. If not, it gives each problem.\n */\nexport const readLimits: (data: unknown) => Result<LimitSet, readonly LimitProblem[]> = reader(limitsSchema, checkLimits);\n\nconst scaleSchema = z.enum([\"linear\", \"log\"]);\nconst rangeFields = { unit: z.string(), min: z.number(), max: z.number(), scale: scaleSchema };\nconst commandFields = { argv: z.array(z.string()), cwd: z.string(), env: z.record(z.string(), z.string()) };\nconst commandSchema = z.strictObject(commandFields);\nconst processSchema = z.strictObject({\n ...commandFields,\n ready: z.discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"line\"), text: z.string() }),\n z.strictObject({ kind: z.literal(\"http\"), path: z.string() }),\n ]),\n});\n\n/**\n * This schema accepts the shape of the contract file of an app: each field with its type, and no other\n * field. It does not examine what the fields mean. The function `checkApp` does that.\n */\nexport const appSchema: z.ZodType<AppContract> = z.strictObject({\n format: z.literal(APP_FORMAT),\n id: z.string(),\n title: z.string(),\n repository: z.string(),\n variables: z.array(z.strictObject({ id: z.string(), title: z.string(), kind: z.enum([\"request\", \"level\", \"store\", \"run\"]), ...rangeFields })),\n classes: z.array(\n z.strictObject({\n id: z.string(),\n title: z.string(),\n rate: z.strictObject(rangeFields),\n request: z.array(z.string()),\n entry: z.discriminatedUnion(\"kind\", [\n z.strictObject({\n kind: z.literal(\"http\"),\n method: z.enum([\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\"]),\n path: z.string(),\n body: z.string().optional(),\n }),\n z.strictObject({ kind: z.literal(\"service\"), service: z.string() }),\n ]),\n }),\n ),\n start: z.strictObject({\n install: commandSchema.optional(),\n check: commandSchema.optional(),\n seed: commandSchema.optional(),\n run: processSchema.extend({\n lines: z.array(z.strictObject({ kind: z.enum(APP_LINE_KINDS), ev: z.string(), title: z.string() })).optional(),\n }),\n }),\n services: z.array(z.strictObject({ id: z.string(), title: z.string(), fake: processSchema })),\n metrics: z.array(\n z.strictObject({\n id: z.string(),\n kind: z.enum([\"counter\", \"gauge\"]),\n unit: z.string(),\n of: z.union([\n z.strictObject({ rate: z.string() }),\n z.strictObject({ level: z.string() }),\n z.strictObject({ total: z.string(), class: z.string() }),\n z.strictObject({ measure: z.string() }),\n ]),\n }),\n ),\n});\n\n/**\n * This function reads the contract of an app from the data of a contract file. It gives the contract when\n * the data has the shape of one and `checkApp` finds no problem. If not, it gives each problem.\n */\nexport const readApp: (data: unknown) => Result<AppContract, readonly AppProblem[]> = reader(appSchema, checkApp);\n"],"mappings":";;;;;;AAuBA,MAAM,aAAa,UAA4B;CAC7C,MAAM,OAAO,KAAK,UAAU,KAAK;CACjC,OAAO,SAAS,KAAA,KAAa,MAAM,MAAM,WAAW,CAAC,CAAC;AACxD;;;;;AAMA,MAAM,UACqB,QAAsB,WAC9C,SAAiE;CAChE,MAAM,QAAQ,OAAO,UAAU,IAAI;CACnC,IAAI,CAAC,MAAM,SACT,OAAO,IAAI,MAAM,MAAM,OAAO,KAAK,WAAW;EAAE,MAAM;EAAS,MAAM,MAAM,KAAK,KAAK,GAAG;EAAG,SAAS,MAAM;CAAQ,EAAE,CAAC;CAEvH,MAAM,WAAW,MAAM,MAAM,IAAI;CACjC,OAAO,SAAS,SAAS,IAAI,IAAI,QAAQ,IAAI,GAAG,MAAM,IAAI;AAC5D;AAEF,MAAM,iBAAiB,EAAE,aAAa;CAAE,KAAK,EAAE,OAAO;CAAG,MAAM,EAAE,OAAO;AAAE,CAAC;AAE3E,MAAM,YAAY,EAAE,aAAa;CAAE,KAAK,EAAE,OAAO;CAAG,QAAQ,EAAE,OAAO;CAAG,MAAM,EAAE,OAAO;AAAE,CAAC;;;;;AAM1F,MAAa,YAA4B,EAAE,aAAa;CACtD,QAAQ,EA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es",
|
|
4
|
+
"title": "The routes line of alerts: the largest routes that start with the heap headroom, at each heap limit",
|
|
5
|
+
"brackets": [
|
|
6
|
+
"alerts-start-routes-limit",
|
|
7
|
+
"alerts-start-routes-limit-mid",
|
|
8
|
+
"alerts-start-routes-limit-home"
|
|
9
|
+
],
|
|
10
|
+
"limits": "alerts-scale",
|
|
11
|
+
"limit": "heap",
|
|
12
|
+
"variable": {
|
|
13
|
+
"id": "routes",
|
|
14
|
+
"unit": "{route}"
|
|
15
|
+
},
|
|
16
|
+
"measure": {
|
|
17
|
+
"id": "heapPeak",
|
|
18
|
+
"unit": "B"
|
|
19
|
+
},
|
|
20
|
+
"unit": "B",
|
|
21
|
+
"headroom": 0.2,
|
|
22
|
+
"points": [
|
|
23
|
+
{
|
|
24
|
+
"plan": "alerts-start-routes-limit",
|
|
25
|
+
"ceiling": 556269568,
|
|
26
|
+
"cpus": [
|
|
27
|
+
"AMD EPYC 7763 64-Core Processor",
|
|
28
|
+
"AMD EPYC 9V45 96-Core Processor",
|
|
29
|
+
"AMD EPYC 9V74 80-Core Processor",
|
|
30
|
+
"INTEL(R) XEON(R) PLATINUM 8573C",
|
|
31
|
+
"Intel(R) Xeon(R) 6975P-C"
|
|
32
|
+
],
|
|
33
|
+
"hold": 60480,
|
|
34
|
+
"held": "persons-60-incidents-1000",
|
|
35
|
+
"fail": 68000,
|
|
36
|
+
"failed": [
|
|
37
|
+
"persons-1000-incidents-60",
|
|
38
|
+
"persons-70-incidents-1000"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"plan": "alerts-start-routes-limit-mid",
|
|
43
|
+
"ceiling": 1174405120,
|
|
44
|
+
"cpus": [
|
|
45
|
+
"AMD EPYC 7763 64-Core Processor",
|
|
46
|
+
"AMD EPYC 9V45 96-Core Processor",
|
|
47
|
+
"AMD EPYC 9V74 80-Core Processor",
|
|
48
|
+
"Intel(R) Xeon(R) 6975P-C"
|
|
49
|
+
],
|
|
50
|
+
"hold": 183000,
|
|
51
|
+
"held": "persons-1000-incidents-175",
|
|
52
|
+
"fail": 201600,
|
|
53
|
+
"failed": [
|
|
54
|
+
"persons-1000-incidents-200",
|
|
55
|
+
"persons-200-incidents-1000"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"plan": "alerts-start-routes-limit-home",
|
|
60
|
+
"ceiling": 2348810240,
|
|
61
|
+
"cpus": [
|
|
62
|
+
"AMD EPYC 7763 64-Core Processor",
|
|
63
|
+
"AMD EPYC 9V45 96-Core Processor",
|
|
64
|
+
"INTEL(R) XEON(R) PLATINUM 8573C",
|
|
65
|
+
"Intel(R) Xeon(R) 6975P-C",
|
|
66
|
+
"Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz"
|
|
67
|
+
],
|
|
68
|
+
"hold": 408000,
|
|
69
|
+
"held": "persons-1000-incidents-400",
|
|
70
|
+
"fail": 458000,
|
|
71
|
+
"failed": [
|
|
72
|
+
"persons-1000-incidents-450",
|
|
73
|
+
"persons-1000-incidents-500",
|
|
74
|
+
"persons-500-incidents-1000"
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": "capacity-limits/1",
|
|
3
|
+
"id": "alerts-scale",
|
|
4
|
+
"title": "The limits of one copy of alerts for its scale rule",
|
|
5
|
+
"limits": [
|
|
6
|
+
{ "id": "cpu", "measure": "cpu", "ceiling": { "kind": "resource", "resource": "cpu" }, "headroom": 0.3 },
|
|
7
|
+
{ "id": "memory", "measure": "memory", "ceiling": { "kind": "resource", "resource": "memory" }, "headroom": 0.2 },
|
|
8
|
+
{ "id": "heap", "measure": "heap", "ceiling": { "kind": "resource", "resource": "heap" }, "headroom": 0.2 }
|
|
9
|
+
]
|
|
10
|
+
}
|