RepositoryGo
x-mod

x-mod/routine

go routine control, abstraction of the Main and some useful Executors.如果你不会管理Goroutine的话,用它

63sao
8fork
0issue
2lượt xem

🧵 routine: Quản lý goroutine và lập lịch công việc phức tạp bằng Go

routine cung cấp abstraction của Main và nhiều executor hữu ích giúp bạn kiểm soát goroutine một cách dễ dàng.

routine là một thư viện Go giúp bạn kiểm soát và quản lý goroutine một cách có hệ thống. Thay vì tự viết logic phức tạp để xử lý đồng thời, routine cung cấp hàm Main để bao bọc logic chính, kèm theo các executor như retry, crontab, concurrent... giúp bạn xây dựng luồng thực thi phức tạp chỉ với vài dòng code.

✨ Điểm nổi bật

  • Main Routine: Cung cấp hàm routine.Main để bao bọc logic chính của ứng dụng.
  • Executor đa dạng: Hỗ trợ timeout, retry, repeat, concurrent, crontab, parallel, sequence, command, profiling.
  • Quản lý vòng đời: Hỗ trợ prepare, cleanup và xử lý signal.
  • Dễ dàng cấu hình: Tạo routine tùy chỉnh bằng routine.New(opts...).Execute(ctx).
  • Hỗ trợ lệnh hệ thống: Chạy lệnh như echo thông qua routine.Command.
  • Lập lịch định kỳ: Dùng routine.Crontab để chạy job theo lịch.
  • Theo dõi hiệu năng: Có hỗ trợ profiling và trace để debug goroutine.

💡 Vì sao đáng chú ý

routine khác biệt ở chỗ nó không chỉ giúp bạn tạo goroutine mà còn cung cấp một kiến trúc rõ ràng với Main, Prepare, Cleanup và Child routines. Kết hợp với các executor mạnh mẽ như retry, timeout hay crontab, bạn có thể xây dựng hệ thống lập lịch công việc phức tạp mà không cần viết thêm logic quản lý đồng thời.

Thích hợp cho các ứng dụng Go cần chạy nhiều công việc đồng thời, lập lịch định kỳ, hoặc thực thi lệnh hệ thống một cách có kiểm soát.


#Go #Goroutine #JobScheduler #Crontab #Retry #Concurrent #TiniX

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryShell
liujianping/job

JOB, make your short-term command as a long-term job. 将命令行规划成任务的工具

151
Jun 30, 2020
RepositoryGo
vardius/gollback

Go asynchronous simple function utilities, for managing execution of closures and callbacks

122
Nov 21, 2026
RepositoryHTML
agenda/agenda

Lightweight job scheduling for Node.js

9.7k
Nov 13, 2026
RepositoryRust
jiawesoft/jiascheduler

A high-performance, scalable, dynamically configured job scheduler developed with rust

518
Nov 14, 2026
RepositoryPython
ptweezy/cronstable

A job scheduler with retries, alerts, saved run history, workflows, and dashboards for single machines and clusters.

140
Dec 1, 2026
RepositoryGo
panjf2000/ants

🐜🐜🐜 ants is the most powerful and reliable pooling solution for Go.

14.5k
Sep 19, 2026
RepositoryGo
go-resty/resty

Simple HTTP, REST, and SSE client library for Go

11.8k
Nov 15, 2026
RepositoryGo
ouqiang/gocron

定时任务管理系统

6.3k
Mar 27, 2024
RepositoryGo
dagucloud/dagu

Self-hostable workflow orchestrator for teams whose main work isn't orchestration. Declarative YAML over your scripts, SSH commands, containers, etc; keep workflows separate from business logic. One binary, no database, runs on limited H/W resources. Alternative to Airflow / Cron / Job Scheduler.

4.7k
Nov 27, 2026