Skip to content
notduncansmithPublic

About

A basic batch queue for Go

Resources

Stars

3 stars

Watchers

1 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

Repository files navigation

bbq - a basic batch queue for Go

GoDoc Build Status codecov

bbq allows you to batch messages by time or count, then flush them to a function of your choice. bbq is thread-safe, utilizing Go's native sync.RWMutex. Flushes are synchronous. If the queue is empty, the flush function will not be called.

Usage

package main

import (
    "fmt"
    "github.com/notduncansmith/bbq"
)

func main() {
    flush := func(ms []interface{}) error {
	for _, m := range ms {
		fmt.Println(m.(string))
	}
	return nil
    }
    q := bbq.NewBatchQueue(flush, BatchQueueOptions{time.Millisecond, 2})
    q.Enqueue("🍖")
    time.Sleep(time.Millisecond)
    // Output:
    // 🍖
}

License

Released under The MIT License (see LICENSE.txt).

Copyright 2019 Duncan Smith

About

A basic batch queue for Go

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

⌂ 换网址