Repository navigation
hop→waker 迁移 · 实现(SDK 接入 + 任务注册 + 双模式部署 + 可观测) - #162
Merged
todosdev[bot] merged 1 commit intoOct 28, 2026
Merged
Conversation
- Run the nightly cleanup from both the native Cron Trigger and a signed
waker callback; dedupe executionId in {prefix}waker_executions (schema_v3).
- Rewrite wrangler config per WAKER_MODE/WAKER_TRIGGERS, inject the signing
key only in waker mode, and gate deploys on secret bindings and schedules.
- Document both deployment modes, switch order and rollback in README (en/zh).
Checkpoint: Ex4plfNZMsFjYlhm3htQZ
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.
Summary
@workerhub/waker-client官方 SDK(源码形态引入),支持将每日清理任务(0 3 * * *)调度平滑接入 waker 平台回调,保留原生 CF Cron Trigger 默认模式,自部署零额外依赖。runCleanup(env),原生scheduled()与POST /_waker/execute共享同一份删除判据与事务语义;新增 D1 加法迁移schema_v3(waker_executions)用于executionId幂等认领。WAKER_MODE=cron|waker与WAKER_TRIGGERS=keep|remove双模式改写、secrets 文件按需注入WAKER_SIGNING_KEY以及发布期 Cloudflare API cron schedules 与密钥绑定双重闸门校验。Changes
apps/worker/src/waker/:逐字拷贝 waker 官方 SDK 2.0.0 源文件(commit2b1eb68)与 README;apps/worker/src/routes/waker.ts:挂载/_waker回调路由;非 waker 模式显式响应 JSON 404(waker_disabled),防止落入 SPA 兜底 200;apps/worker/src/services/cleanup.ts:抽离统一清理函数(verifications与totp_used批量删除);apps/worker/src/services/waker.ts:组装带 D1 账本与签名验签的 receiver,产出结构化可观测日志;apps/worker/src/index.ts:注册/_waker路由并使scheduled()委托统一清理函数。apps/worker/src/lib/migrations.ts&apps/worker/migrations/0003_waker_executions.sql:新增schema_v3幂等账本表,列定义与 SDKexecutionLedgerDdl()严格一致。.github/scripts/configure-waker-mode.mjs:部署期按变量重写wrangler.toml;.github/workflows/deploy.yml:增加模式配置步、secrets 文件条件注入与 verify 参数传递;.github/scripts/verify-deployment.sh:断言发布版本上的WAKER_SIGNING_KEY绑定及 Cloudflare schedules。README.md&README.zh-CN.md:增加双模式部署、参数规范、切换与回滚说明;waker-callback.test.ts、waker-schema.test.ts、test-waker-mode.mjs等完备测试用例。Testing
pnpm check(Biome 代码检查与格式化 119 files 全部通过)pnpm typecheck(TypeScript 类型检查全部通过)pnpm test(Worker 129 tests、Web 55 tests + 4 Vitest DOM 全部通过)node --test .github/scripts/test-deploy-checks.mjs .github/scripts/test-waker-mode.mjs(62 tests 全部通过)node --test .github/scripts/test-d1-migrations.mjs(18 tests 全部通过)shellcheck .github/scripts/*.sh(通过)wrangler deploy --dry-run(验证 cron 与 waker 模式产物及绑定符合预期)