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-10-16 10:50:43 +08:00
|
|
|
if err := executor.Add(1); err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-07-26 17:09:05 +08:00
|
|
|
time.Sleep(time.Millisecond * 90)
|
|
|
|
}
|
|
|
|
}
|