YTask 是 Go 的异步任务队列,比起其他框架更方便快捷。
架构图:
特性:
安装
go get github.com/gojuukaze/YTask/v2
注册任务
type User struct{ ... } // 任务函数 func DemoFunc(a int, b float64, c []string, user User) (int, []User, string) { .... return .... } ... ser.Add("group1", "demo_func", DemoFunc)
调用任务
taskId, _ = client.Send("group1", "demo_func", 11, 22.2, []string{"bb", "cc"}, User{"hh",24})
获取结果
result, _ = client.GetResult(taskId, 2*time.Second, 300*time.Millisecond) var a int var b []User var c string a, _ = result.GetInt64(0) // or result.Get(1,&b) // or result.Gets(&a, &b, &c)