x-mod / Routine
Licence: mit
go routine control, abstraction of the Main and some useful Executors.如果你不会管理Goroutine的话,用它
Stars: ✭ 40
Programming Languages
go
31211 projects - #10 most used programming language
Projects that are alternatives of or similar to Routine
Fgbase
Ready-send coordination layer on top of goroutines.
Stars: ✭ 45 (+12.5%)
Mutual labels: concurrent, goroutine
Job
JOB, make your short-term command as a long-term job. 将命令行规划成任务的工具
Stars: ✭ 98 (+145%)
Mutual labels: crontab, retry
goroutines
provides utilities to perform common tasks on goroutines
Stars: ✭ 19 (-52.5%)
Mutual labels: concurrent, goroutine
Batchman
This library for Android will take any set of events and batch them up before sending it to the server. It also supports persisting the events on disk so that no event gets lost because of an app crash. Typically used for developing any in-house analytics sdk where you have to make a single api call to push events to the server but you want to optimize the calls so that the api call happens only once per x events, or say once per x minutes. It also supports exponential backoff in case of network failures
Stars: ✭ 50 (+25%)
Mutual labels: job-scheduler, retry
Ppgo job
PPGo_Job是一款可视化的、多人多权限的、一任务多机执行的定时任务管理系统,采用golang开发,安装方便,资源消耗少,支持大并发,可同时管理多台服务器上的定时任务。
Stars: ✭ 1,152 (+2780%)
Mutual labels: crontab, job-scheduler
Gollback
Go asynchronous simple function utilities, for managing execution of closures and callbacks
Stars: ✭ 55 (+37.5%)
Mutual labels: goroutine, retry
retrygroup
Package retrygroup provides synchronization, Context cancelation for groups of retry goroutines working on subtasks of a common task.
Stars: ✭ 18 (-55%)
Mutual labels: retry, goroutine
Cronsun
A Distributed, Fault-Tolerant Cron-Style Job System.
Stars: ✭ 2,493 (+6132.5%)
Mutual labels: crontab, job-scheduler
Go Quartz
Simple, zero-dependency scheduling library for Go
Stars: ✭ 118 (+195%)
Mutual labels: crontab, job-scheduler
Chronos
Fault tolerant job scheduler for Mesos which handles dependencies and ISO8601 based schedules
Stars: ✭ 4,303 (+10657.5%)
Mutual labels: crontab, job-scheduler
gronx
Lightweight, fast and dependency-free Cron expression parser (due checker), task scheduler and/or daemon for Golang (tested on v1.13 and above) and standalone usage
Stars: ✭ 206 (+415%)
Mutual labels: crontab, job-scheduler
Resilience4j
Resilience4j is a fault tolerance library designed for Java8 and functional programming
Stars: ✭ 7,521 (+18702.5%)
Mutual labels: retry
Cron Parser
Node.js library for parsing crontab instructions
Stars: ✭ 802 (+1905%)
Mutual labels: crontab
Dynamic Wallpaper
A simple bash script to set wallpapers according to current time, using cron job scheduler.
Stars: ✭ 762 (+1805%)
Mutual labels: crontab
Octopoller.rb
A micro gem for polling and retrying. Perfect for making repeating requests.
Stars: ✭ 30 (-25%)
Mutual labels: retry
routine
Routine Architecture
Quick Start
package main
import (
"log"
"context"
"github.com/x-mod/routine"
)
func main(){
if err := routine.Main(
context.TODO(),
routine.Command("echo", routine.ARG("hello routine!")),
); err != nil {
log.Fatal(err)
}
}
Or you can just clone the repo, then running go run quickstart/main.go
.
Main Routine
The most functional feature is providing the Main
function abstraction, you can use the routine.Main
to wrap your main function logic very quickly.
package main
import (
"context"
"github.com/x-mod/routine"
)
func MainGo(ctx context.Context) error {
log.Println("this is the Main Go func")
return nil
}
func ChildGo(ctx context.Context) error {
log.Println("this is the Child Go func")
return nil
}
func prepareGo(ctx context.Context) error {
log.Println("this is the prepare Go func")
return nil
}
func cleanupGo(ctx context.Context) error {
log.Println("this is the Clean Go func")
return nil
}
func main(){
log.Println(
routine.Main(
context.TODO(),
//main Go
routine.ExecutorFunc(MainGo),
//prpare Go
routine.Prepare(routine.ExecutorFunc(prepareGo)),
//cleanup Go
routine.Cleanup(routine.ExecutorFunc(cleanupGo)),
routine.Go(routine.ExecutorFunc(ChildGo)),//child Go
routine.Go(routine.ExecutorFunc(ChildGo)),
routine.Go(routine.ExecutorFunc(ChildGo)),
//signals
routine.Signal(syscall.SIGINT, routine.SigHandler(func() {
os.Exit(1)
})),
),
)
}
Routine
create and control your own routine by routine.New
.
import "github.com/x-mod/routine"
err := routine.New(opts...).Execute(ctx)
Executors
The package provides many useful executor adapters for you:
- guarantee
- timeout & deadline
- retry & repeat
- concurrent
- crontab
- parallel & sequence
- command
- profiling
with these executor adapters, you can building the most complex goroutine logic.
import "github.com/x-mod/routine"
//timeout
timeout := routine.Timeout(time.Minute, exec)
//retry
retry := routine.Retry(3, exec)
//repeat
repeat := routine.Repeat(10, time.Second, exec)
//concurrent
concurrent := routine.Concurrent(4, exec)
//schedule executor
crontab := routine.Crontab("* * * * *", exec)
//command
command := routine.Command("echo", routine.ARG("hello routine!"))
//parallel
parallel := routine.Parallel(exec1, exec2, exec3, ...)
//sequence
sequece := routine.Append(exec1, exec2, exec3, ...)
Enjoy
More details, please check the example and trace it.
$: go run example/main.go
# trace go routine & tasks
$: go tool trace trace.out
Then you can check the tasks like this:
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].