Преглед изворни кода

chore: 组卷任务走 default 队列并补充 PDF 超时与注释

- AssembleExamTaskJob: onQueue(default),与 pdf 队列解耦。\n- config/pdf.php: chrome 轮询与远程图探测超时。\n- composer.json: laravel/pail 列入 dont-discover。\n- QuestionPdfController: 文档补充 source=main。

Made-with: Cursor
yemeishu пре 3 недеља
родитељ
комит
39e3c77c4d

+ 2 - 1
app/Http/Controllers/Api/QuestionPdfController.php

@@ -31,7 +31,8 @@ class QuestionPdfController extends Controller
      *   "student_grade": "初二",       // optional
      *   "teacher_name": "李老师",      // optional
      *   "paper_name": "专项练习",      // optional
-     *   "include_grading": false       // optional, whether to generate grading PDF
+     *   "include_grading": false,      // optional, whether to generate grading PDF
+     *   "source": "main"             // optional: default=questions_tem;main=questions(正式题库)
      * }
      */
     public function generate(Request $request)

+ 2 - 3
app/Jobs/AssembleExamTaskJob.php

@@ -27,8 +27,8 @@ class AssembleExamTaskJob implements ShouldQueue
     public function __construct(string $taskId)
     {
         $this->taskId = $taskId;
-        // 复用现有 pdf-worker,避免 default 队列无人消费
-        $this->onQueue('pdf');
+        // 组卷任务放到默认队列,与 PDF 队列解耦,降低排队等待
+        $this->onQueue('default');
         $this->afterCommit();
     }
 
@@ -675,4 +675,3 @@ class AssembleExamTaskJob implements ShouldQueue
         return $adjustedQuestions;
     }
 }
-

+ 3 - 1
composer.json

@@ -83,7 +83,9 @@
     },
     "extra": {
         "laravel": {
-            "dont-discover": []
+            "dont-discover": [
+                "laravel/pail"
+            ]
         }
     },
     "config": {

+ 21 - 0
config/pdf.php

@@ -23,4 +23,25 @@ return [
     |
     */
     'include_kp_explain_default' => env('PDF_INCLUDE_KP_EXPLAIN', false),
+
+    /*
+    |--------------------------------------------------------------------------
+    | Chrome 轮询超时(秒)
+    |--------------------------------------------------------------------------
+    |
+    | 主渲染通道等待 PDF 文件落地的最长时长;超时后会快速进入最小参数兜底。
+    | 默认 40 秒(旧逻辑固定 80 秒),用于降低异常场景下的长时间卡顿。
+    |
+    */
+    'chrome_poll_timeout_seconds' => (int) env('PDF_CHROME_POLL_TIMEOUT_SECONDS', 40),
+
+    /*
+    |--------------------------------------------------------------------------
+    | 远程图片尺寸探测超时(秒)
+    |--------------------------------------------------------------------------
+    |
+    | 扁图自适应会探测远程图片宽高。为防止慢图源拖慢 PDF,探测使用短超时。
+    |
+    */
+    'image_probe_timeout_seconds' => (int) env('PDF_IMAGE_PROBE_TIMEOUT_SECONDS', 2),
 ];