feat: 实现 AIO 容器部署

This commit is contained in:
SkyJourney
2026-07-26 16:55:36 +08:00
parent d1b5880a5b
commit 15dd2acfc0
13 changed files with 425 additions and 32 deletions
+36
View File
@@ -8,6 +8,7 @@ import {
PdfRenderTimeoutError,
PlaywrightPdfGenerator,
isAllowedPdfRequestUrl,
readPdfEngineRuntimeLimits,
type PdfRenderPayload
} from "../src/pdf-engine.js";
@@ -102,6 +103,41 @@ describe("PDF 并发控制", () => {
});
});
describe("PDF 运行参数", () => {
it("读取容器环境变量", () => {
expect(
readPdfEngineRuntimeLimits({
PDF_CONCURRENCY: "1",
PDF_MAX_QUEUE: "4",
PDF_TIMEOUT_MS: "120000"
})
).toEqual({
concurrency: 1,
maxQueue: 4,
timeoutMs: 120_000
});
});
it("缺少环境变量时使用默认值", () => {
expect(readPdfEngineRuntimeLimits({})).toEqual({
concurrency: 2,
maxQueue: 8,
timeoutMs: 60_000
});
});
it.each([
["PDF_CONCURRENCY", "0"],
["PDF_MAX_QUEUE", "-1"],
["PDF_TIMEOUT_MS", "999"],
["PDF_CONCURRENCY", "1.5"]
])("拒绝无效的 %s", (name, value) => {
expect(() =>
readPdfEngineRuntimeLimits({ [name]: value })
).toThrow(name);
});
});
describe("PDF 网络策略", () => {
it("只允许渲染同源和内嵌资源", () => {
const origin = "http://127.0.0.1:5173";