https://github.com/mdaliyan/bucket
chunked queue for golang
https://github.com/mdaliyan/bucket
callback-functions chunked golang golang-package queue
Last synced: 3 months ago
JSON representation
chunked queue for golang
- Host: GitHub
- URL: https://github.com/mdaliyan/bucket
- Owner: mdaliyan
- License: mit
- Created: 2019-10-17T07:14:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-23T10:44:44.000Z (about 3 years ago)
- Last Synced: 2024-06-19T05:43:29.372Z (almost 2 years ago)
- Topics: callback-functions, chunked, golang, golang-package, queue
- Language: Go
- Homepage:
- Size: 17.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Bucket

[](https://coveralls.io/github/mdaliyan/bucket?branch=master)
[](https://goreportcard.com/report/github.com/mdaliyan/bucket/v2)
[](https://pkg.go.dev/github.com/mdaliyan/bucket/v2)
[](https://raw.githubusercontent.com/labstack/echo/master/LICENSE)
bucket queues your items and sends them to your callback function in chunks.
### Installation
```bash
go get github.com/mdaliyan/bucket
```
### Usage
```go
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
```