Repository navigation
feat(jobs): 持久化作业队列第一批(#67) - #84
Merged
Merged
Conversation
新增 `uvcpp_job_queue`(`src/uvcpp/uvcpp_job_queue.*`): - 状态 PENDING/RUNNING/SUCCESS/FAILED/CANCELLED,每次变更写 store + on_state; - handler 在 `uvcpp_work` 线程池上同步执行;超时/取消是协作式(置 `ctx.cancelled()`,队列不杀线程),长循环须自行轮询; - `concurrency_key` 非空时同一 key 严格串行;`max_concurrent` 默认 4; - 失败按 `max_retry` 重试,退避 `backoff_ms * 2^(attempt-1)`,封顶 1 小时; - `max_queue` 上限时 submit 拒绝并计 `rejected`; - `start()` 从 store 恢复:上次 RUNNING → PENDING,error 标 `recovered after restart`; - store 接口 + 内存实现(可替换;SQLite/MySQL 与异步 handler 留后续); - stats:pending/running/success/failed/cancelled/retried/rejected。 用例 `job_queue_func`:执行/统计/清理、同 key 最大并发 1、两次失败后成功 (attempt=3、retried=2)、重试耗尽 FAILED、取消 PENDING 与 RUNNING(协作)、 超时标记 timeout、队列满拒绝、RUNNING 记录重启恢复后成功。文档 §13。 本地 build-all 170/170、build-h3/default 编过;五条文档门禁全绿。
Antruly
force-pushed
the
feat/job-queue
branch
from
November 22, 2026 06:06
b07375f to
2779cb4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #67(第一批:内存记录 + 同步 handler;SQLite/MySQL store、异步 handler 留后续)。
内容
新增
uvcpp_job_queue/uvcpp_job_store/uvcpp_memory_job_store:on_state();uvcpp_work线程池上同步跑;超时 / 取消是协作式的(置ctx.cancelled(),队列不杀线程);concurrency_key:同一非空 key 同时只允许一个 RUNNING;max_concurrent默认 4;attempt <= max_retry回 PENDING,退避backoff_ms * 2^(attempt-1)(封顶 1 小时);max_queue > 0且 PENDING 达上限时submit()拒绝并计rejected;start()从 store 读回;上次 RUNNING → PENDING,error 标recovered after restart;stats():pending / running / success / failed / cancelled / retried / rejected;stop()且running == 0。用例
job_queue_func:stats.success=3、clear_finished清理;max_retry=1的常败任务最终 FAILED 且恰好尝试 2 次;cancelled()后退出、状态 CANCELLED;超时 → FAILED 且 error=timeout;max_queue=1:第三个提交被拒绝、rejected=1;start()后变 PENDING + recovered 标记,放行后成功执行。验证
build-all 170/170、build-h3 / build-default 编过;check_docs / check_doc_lines / check_doc_versions / check_ci_layout 全绿。文档
doc/lowlevel-guide.md§13。