convex-crons

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- GENERATED from convex-agents content/capabilities/crons.json — do not edit by hand. -->
<!-- 由convex-agents的content/capabilities/crons.json生成 — 请勿手动编辑。 -->

Add scheduled jobs (crons)

添加定时任务(crons)

Define recurring jobs in convex/crons.ts targeting internal functions, with sane intervals and idempotent handlers.
在convex/crons.ts中定义周期性任务,指向内部函数,设置合理的时间间隔并使用幂等处理器。

Workflow

工作流程

  1. Create convex/crons.ts with cronJobs().
  2. Schedule internal functions (never public api.*) at the right interval.
  3. Make handlers idempotent (safe to re-run); keep each run small.
  4. Verify the job appears in the dashboard schedule.
  1. 创建包含cronJobs()的convex/crons.ts文件。
  2. 为内部函数(绝不能是api.*)设置合适的执行间隔。
  3. 确保处理器具备幂等性(可安全重复执行);保持每次任务执行的体量较小。
  4. 在控制台的任务计划中验证该任务已存在。

Rules

规则

  • Schedule internal.* functions, never api.*.
  • Keep cron handlers small + idempotent.
  • Don't poll tight intervals for things a subscription can push.
  • 仅为internal.函数设置定时任务,绝不能是api.
  • 保持Cron处理器体量小且具备幂等性。
  • 对于可以通过订阅推送的内容,不要设置过短的轮询间隔。