Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 26-Mar-2018 | - | ||||
README.md | H A D | 26-Mar-2018 | 1,016 | 32 | 24 | |
batcher.go | H A D | 26-Mar-2018 | 2.4 KiB | 109 | 72 | |
batcher_test.go | H A D | 26-Mar-2018 | 2 KiB | 124 | 99 |
README.md
1batcher 2======= 3 4[![Build Status](https://travis-ci.org/eapache/go-resiliency.svg?branch=master)](https://travis-ci.org/eapache/go-resiliency) 5[![GoDoc](https://godoc.org/github.com/eapache/go-resiliency/batcher?status.svg)](https://godoc.org/github.com/eapache/go-resiliency/batcher) 6[![Code of Conduct](https://img.shields.io/badge/code%20of%20conduct-active-blue.svg)](https://eapache.github.io/conduct.html) 7 8The batching resiliency pattern for golang. 9 10Creating a batcher takes two parameters: 11- the timeout to wait while collecting a batch 12- the function to run once a batch has been collected 13 14You can also optionally set a prefilter to fail queries before they enter the 15batch. 16 17```go 18b := batcher.New(10*time.Millisecond, func(params []interface{}) error { 19 // do something with the batch of parameters 20 return nil 21}) 22 23b.Prefilter(func(param interface{}) error { 24 // do some sort of sanity check on the parameter, and return an error if it fails 25 return nil 26}) 27 28for i := 0; i < 10; i++ { 29 go b.Run(i) 30} 31``` 32