mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
refactor(domain): charge resource allowances through one Budget owner (#11293)
This commit is contained in:
1 parent
c931ba43ab
commit
3d67404132
11 files changed
+215
-96
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { Budget } from "../domain/budget.js";
|
||||
import {
|
||||
malformedInput,
|
||||
ParseFailureError,
|
||||
@@ -117,13 +118,13 @@ export const modelCapacityReportedLimits = (
|
||||
|
||||
/** Charge representation growth before retaining rows or decoding long strings. */
|
||||
export class ModelReportBudget {
|
||||
#remaining = MODEL_REPORT_BYTES;
|
||||
readonly #bytes = new Budget(MODEL_REPORT_BYTES);
|
||||
charge(bytes: number): void {
|
||||
if (!Number.isSafeInteger(bytes) || bytes < 0 || bytes > this.#remaining)
|
||||
throw modelCapacityFailure(
|
||||
this.#bytes.charge(bytes, () =>
|
||||
modelCapacityFailure(
|
||||
"representation-bytes",
|
||||
"Model facts exceed the 32 MiB retained representation budget. This release has no runtime override.",
|
||||
);
|
||||
this.#remaining -= bytes;
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user