{"id":13413101,"url":"https://github.com/x-mod/routine","last_synced_at":"2026-01-12T13:54:27.467Z","repository":{"id":57486518,"uuid":"173740467","full_name":"x-mod/routine","owner":"x-mod","description":"go routine control, abstraction of the Main and some useful Executors.如果你不会管理Goroutine的话，用它","archived":false,"fork":false,"pushed_at":"2024-01-11T07:24:07.000Z","size":224,"stargazers_count":61,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-07-31T20:51:54.764Z","etag":null,"topics":["concurrent","crontab","goroutine","job-scheduler","repeat","retry"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/x-mod.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-03-04T12:25:23.000Z","updated_at":"2024-05-31T23:58:29.000Z","dependencies_parsed_at":"2024-01-30T04:58:10.918Z","dependency_job_id":null,"html_url":"https://github.com/x-mod/routine","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/x-mod/routine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-mod%2Froutine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-mod%2Froutine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-mod%2Froutine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-mod%2Froutine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/x-mod","download_url":"https://codeload.github.com/x-mod/routine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/x-mod%2Froutine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28339872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrent","crontab","goroutine","job-scheduler","repeat","retry"],"created_at":"2024-07-30T20:01:33.471Z","updated_at":"2026-01-12T13:54:27.445Z","avatar_url":"https://github.com/x-mod.png","language":"Go","readme":"routine\n===\n[![GoDoc](https://godoc.org/github.com/x-mod/routine?status.svg)](https://godoc.org/github.com/x-mod/routine) [![Go Report Card](https://goreportcard.com/badge/github.com/x-mod/routine)](https://goreportcard.com/report/github.com/x-mod/routine) [![Build Status](https://travis-ci.org/x-mod/routine.svg?branch=master)](https://travis-ci.org/x-mod/routine) [![Version](https://img.shields.io/github/tag/x-mod/routine.svg)](https://github.com/x-mod/routine/releases) [![Coverage Status](https://coveralls.io/repos/github/x-mod/routine/badge.svg?branch=master)](https://coveralls.io/github/x-mod/routine?branch=master)\n\n\n## Routine Architecture\n\n![](docs/routine.png)\n\n## Quick Start\n\n````go\npackage main\n\nimport (\n\t\"log\"\n\t\"context\"\n\n\t\"github.com/x-mod/routine\"\n)\n\nfunc main(){\n\tif err := routine.Main(\n\t\tcontext.TODO(),\n\t\troutine.Command(\"echo\", routine.ARG(\"hello routine!\")),\n\t); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n````\n\nOr you can just clone the repo, then running `go run quickstart/main.go`.\n\n## Main Routine\n\nThe most functional feature is providing the `Main` function abstraction, you can use the `routine.Main` to wrap your main function logic very quickly.\n\n````go\npackage main\n\nimport (\n\t\"context\"\n\t\"github.com/x-mod/routine\"\n)\n\nfunc MainGo(ctx context.Context) error {\n\tlog.Println(\"this is the Main Go func\")\n\treturn nil\n}\nfunc ChildGo(ctx context.Context) error {\n\tlog.Println(\"this is the Child Go func\")\n\treturn nil\n}\nfunc prepareGo(ctx context.Context) error {\n\tlog.Println(\"this is the prepare Go func\")\n\treturn nil\n}\nfunc cleanupGo(ctx context.Context) error {\n\tlog.Println(\"this is the Clean Go func\")\n\treturn nil\n}\n\nfunc main(){\n\tlog.Println(\n\t\troutine.Main(\n\t\t\tcontext.TODO(),\n\t\t\t//main Go\n\t\t\troutine.ExecutorFunc(MainGo),\n\t\t\t//prpare Go\n\t\t\troutine.Prepare(routine.ExecutorFunc(prepareGo)),\n\t\t\t//cleanup Go\n\t\t\troutine.Cleanup(routine.ExecutorFunc(cleanupGo)),\n\t\t\troutine.Go(routine.ExecutorFunc(ChildGo)),//child Go\n\t\t\troutine.Go(routine.ExecutorFunc(ChildGo)),\n\t\t\troutine.Go(routine.ExecutorFunc(ChildGo)),\n\t\t\t//signals\n\t\t\troutine.Signal(syscall.SIGINT, routine.SigHandler(func() {\n\t\t\t\tos.Exit(1)\n\t\t\t})),\n\t\t),\n\t)\n}\n\n````\n\n## Routine\n\ncreate and control your own routine by `routine.New`.\n\n````go\n\nimport \"github.com/x-mod/routine\"\n\nerr := routine.New(opts...).Execute(ctx)\n\n````\n\n## Executors\n\nThe package provides many useful executor adapters for you:\n\n- guarantee\n- timeout \u0026 deadline\n- retry \u0026 repeat\n- concurrent\n- crontab\n- parallel \u0026 sequence\n- command\n- profiling\n\nwith these executor adapters, you can building the most complex goroutine logic.\n\n````go\n\nimport \"github.com/x-mod/routine\"\n\n//timeout\ntimeout := routine.Timeout(time.Minute, exec)\n\n//retry\nretry := routine.Retry(3, exec)\n\n//repeat\nrepeat := routine.Repeat(10, time.Second, exec)\n\n//concurrent\nconcurrent := routine.Concurrent(4, exec)\n\n//schedule executor\ncrontab := routine.Crontab(\"* * * * *\", exec)\n\n//command\ncommand := routine.Command(\"echo\", routine.ARG(\"hello routine!\"))\n\n//parallel\nparallel := routine.Parallel(exec1, exec2, exec3, ...)\n\n//sequence\nsequece := routine.Append(exec1, exec2, exec3, ...)\n````\n\n# Enjoy\n\nMore details, please check the [example](example/main.go) and trace it.\n\n````bash\n$: go run example/main.go\n\n# trace go routine \u0026 tasks\n$: go tool trace  trace.out\n````\n\nThen you can check the tasks like this:\n\n![](docs/usetasks.png)\n","funding_links":[],"categories":["Goroutines","Goroutines `goroutines的管理和使用`","Relational Databases"],"sub_categories":["Search and Analytic Databases","Advanced Console UIs","检索及分析资料库","SQL 查询语句构建库"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-mod%2Froutine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fx-mod%2Froutine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fx-mod%2Froutine/lists"}