@danypops/vehicle-core 0.18.3 → 0.18.4
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/dist/index.d.ts +6 -4
- package/dist/index.js +6 -4
- package/dist/resource-pool/bounded-resource-pool.d.ts +139 -0
- package/dist/resource-pool/bounded-resource-pool.js +427 -0
- package/dist/resource-pool/errors.d.ts +24 -0
- package/dist/resource-pool/errors.js +44 -0
- package/dist/resource-pool/index.d.ts +3 -0
- package/dist/resource-pool/index.js +3 -0
- package/dist/resource-pool/resource-policy.d.ts +28 -0
- package/dist/resource-pool/resource-policy.js +1 -0
- package/package.json +1 -1
- package/src/index.ts +6 -4
- package/src/resource-pool/bounded-resource-pool.ts +506 -0
- package/src/resource-pool/errors.ts +45 -0
- package/src/resource-pool/index.ts +3 -0
- package/src/resource-pool/resource-policy.ts +29 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Which ceiling actually constrained the most recent admission decision. */
|
|
2
|
+
export type ResourcePoolActiveCeilingSource = "configured" | "resource-budget" | "absolute-cap";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Optional plug point letting a real resource budget (memory, /proc-sampled process cost, ...)
|
|
6
|
+
* drive admission and retention decisions beyond the pool's own configured counts. A pool without
|
|
7
|
+
* one falls back to its configured maxActive/absoluteMaxActive alone -- this interface exists so a
|
|
8
|
+
* caller CAN plug in something smarter, not because every caller needs to.
|
|
9
|
+
*
|
|
10
|
+
* `Status` is left to the caller (default `unknown`) rather than fixed to one shape: the pool
|
|
11
|
+
* itself never inspects or reshapes what `status()` returns, only forwards it verbatim in its own
|
|
12
|
+
* status() report -- a caller with an existing status shape (its own field names, units, wire
|
|
13
|
+
* contract) plugs it in unchanged, no adapter required.
|
|
14
|
+
*/
|
|
15
|
+
export interface ResourcePoolResourcePolicy<Status = unknown> {
|
|
16
|
+
canAdmit(activePartitions: readonly string[], requestedPartition: string): boolean;
|
|
17
|
+
isOverBudget(activePartitions: readonly string[]): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* A conservative, count-shaped ceiling derived from a real budget and worst-case known
|
|
20
|
+
* per-partition cost -- lets a larger real budget actually raise how many resources the pool
|
|
21
|
+
* will try to keep active, instead of a fixed configured count being the permanent bottleneck
|
|
22
|
+
* regardless of how much is genuinely available. Never authoritative on its own: canAdmit's own
|
|
23
|
+
* precise per-attempt check still gates the actual admission. Returns undefined on any metric
|
|
24
|
+
* loss -- fails closed, never treated as "unlimited room."
|
|
25
|
+
*/
|
|
26
|
+
softActiveCeiling(activePartitions: readonly string[]): number | undefined;
|
|
27
|
+
maxIdleMs(configuredMaxIdleMs: number, activePartitions: readonly string[]): number;
|
|
28
|
+
status(activePartitions: readonly string[]): Status;
|
|
29
|
+
}
|