bucket queues your items and sends them to your callback function in chunks.
go get github.com/mdaliyan/bucket
callback := func(items []interface{}) {
fmt.Println(items)
}
b, _ := bucket.New(bucket.BySize(10), callback)
for i := 0; i < 25; i++ {
b.Push(i)
}
time.Sleep(time.Microsecond * 100)
fmt.Println(b.Len())
this Prints
[0 1 2 3 4 5 6 7 8 9]
[10 11 12 13 14 15 16 17 18 19]
5