Chuyển đến nội dung
Skillpedia
Tự động hóa25k · #10105

nocobase-app-plugin-scheduler

Skill này làm gì

Skill này hướng dẫn lập trình viên xây dựng tác vụ định kỳ trong ứng dụng NocoBase 3, với trạng thái hiển thị cho quản trị viên nghiệp vụ. Skill dành cho các nhóm cần theo dõi công việc lặp lại.

Khi nào nên dùng

  • ✓Khi quản trị viên nghiệp vụ cần xem và theo dõi các tác vụ lặp lại trong ứng dụng.
  • ✓Khi bạn muốn định nghĩa lịch trong mã với trạng thái hiển thị trong giao diện.
  • ✓Khi một tác vụ nền không cần hiển thị trên giao diện, và bạn cần chọn cơ chế công việc khác.

Liên kết skill

https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-scheduler/skills/nocobase-app-plugin-scheduler/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-scheduler/skills/nocobase-app-plugin-scheduler/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể thêm một tác vụ chạy hằng đêm để lưu trữ các đơn hàng cũ, và cho quản trị viên xem các lần chạy và tắt nó đi không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

AI định nghĩa lịch và logic thực thi trong mã, đăng ký mục tiêu và báo cáo trạng thái cuối cùng. Scheduler giữ lịch sử kích hoạt để quản trị viên theo dõi từng lần chạy.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Develop Scheduled Tasks in an Application

Use the installed version's public exports, without importing plugin internals. The application owns business logic, schedule declarations, Providers, permissions, and deployment timing. Scheduler owns scheduling projections, trigger history, and execution state. The plugin's skills/ directory is the source of truth; do not edit the synchronized application copy under .agents/skills/.

Decide Whether to Use Scheduler

The primary reason to define tasks through Scheduler is UI observability for business administrators. Developers define schedules and execution logic in code. Business administrators use the task list and detail pages the application builds on the Scheduler API to view schedules, track individual executions, and enable or disable tasks when authorized.

Tasks that do not need to be viewed and tracked through the UI must not be managed by the Scheduler plugin. Give recurring ones a ScheduleExecutor of their own from the application's jobs service (jobExecutorServiceToken in @nocobase/app-server/jobs), and one-off background work a JobExecutor; the application development Skill describes both. For administrator-visible tasks, deliver Client registration, access permissions, meaningful task names, and accurate final execution status together; successful server-side dispatch alone is incomplete.

Then Choose the Execution Model

After deciding to use Scheduler, choose according to business complexity:

Scenario Choice Implementation boundary
Periodic cleanup, cache refresh, a single report, or one business Service call Own target type Short operations may complete directly; hand lengthy work to a JobExecutor
A simple operation that happens hourly Own target type Cron alone is not a reason to introduce a heavier execution system
Immediate asynchronous execution JobExecutor No Cron Schedule is needed
A one-time delay, such as ten minutes after a request Queue delay No Cron Schedule is needed; JobExecutor has no delay
Another execution system with its own references, status queries, and completion protocol Own target type The same registerTarget() call, with inspect() and completion reporting for work that finishes later

Every schedule points at a registered target; registerTarget() is the target extension surface, and there is no built-in target type. A target does not guarantee exactly-once external business effects; design business idempotency.

Read by Task

Development Loop

  1. Establish which tasks and execution records administrators need to see. Check Server/Client/CLI registration, page permissions, the application's jobs configuration (a redis adapter for more than one instance; memory serves one process) and JobExecutorServiceProvider composition and target availability, then choose or register the target type.
  2. Implement business logic and Providers in application source, and call schedulerServiceToken.defineSchedule(definition) with an application-wide stable key from that Provider's register()/boot().
  3. Validate payload/inpu
Câu hỏi thường gặp

Mọi công việc nền có nên dùng Scheduler không?

Không. Skill nói rằng các tác vụ không cần hiển thị trên giao diện thì không nên dùng nó.

Ai có thể bật hoặc tắt một tác vụ?

Quản trị viên nghiệp vụ được ủy quyền, thông qua giao diện.

Scheduler có chứa logic nghiệp vụ không?

Không. Ứng dụng sở hữu logic, còn Scheduler xử lý lịch và trạng thái.

Chi tiết

Mô tả gốc của tác giả

Develop scheduled tasks in NocoBase 3 that business administrators need to view and track through the application UI. Define schedules in code, register the target a schedule points at, integrate execution status, and report completion. Do not use Scheduler to manage tasks that do not need UI visibility.

repo: nocobase/nocobase

Độ phổ biến

Sao GitHub
25k
Vị trí xếp hạng
#10105
Giấy phép
—
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự