pe.go 353 B

12345678910111213141516171819202122
  1. package main
  2. import (
  3. "fmt"
  4. "time"
  5. "github.com/tal-tech/go-zero/core/executors"
  6. )
  7. func main() {
  8. executor := executors.NewBulkExecutor(func(items []interface{}) {
  9. fmt.Println(len(items))
  10. }, executors.WithBulkTasks(10))
  11. for {
  12. if err := executor.Add(1); err != nil {
  13. fmt.Println(err)
  14. return
  15. }
  16. time.Sleep(time.Millisecond * 90)
  17. }
  18. }