go-zero/example/periodicalexecutor/pe.go

19 lines
294 B
Go
Raw Normal View History

2020-07-26 17:09:05 +08:00
package main
import (
2020-08-11 12:44:21 +08:00
"fmt"
2020-07-26 17:09:05 +08:00
"time"
2020-08-08 16:40:10 +08:00
"github.com/tal-tech/go-zero/core/executors"
2020-07-26 17:09:05 +08:00
)
func main() {
2020-08-16 22:25:51 +08:00
executor := executors.NewBulkExecutor(func(items []interface{}) {
2020-08-11 12:44:21 +08:00
fmt.Println(len(items))
2020-07-26 17:09:05 +08:00
}, executors.WithBulkTasks(10))
for {
2020-08-16 22:25:51 +08:00
executor.Add(1)
2020-07-26 17:09:05 +08:00
time.Sleep(time.Millisecond * 90)
}
}