aboutsummaryrefslogtreecommitdiffstats
path: root/skate/zipkey
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-07-08 00:16:18 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-07-08 00:16:18 +0200
commit4ba813475b3e722e2d78c0a485bd15bbb0727fce (patch)
tree33326c9cf63716844a1495cc12f536bb52d68923 /skate/zipkey
parent7a5fbfc41c8c71576e4788c7ba891979c6f5f1a8 (diff)
downloadrefcat-4ba813475b3e722e2d78c0a485bd15bbb0727fce.tar.gz
refcat-4ba813475b3e722e2d78c0a485bd15bbb0727fce.zip
reduce: separate batch calls
Diffstat (limited to 'skate/zipkey')
-rw-r--r--skate/zipkey/batch.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/skate/zipkey/batch.go b/skate/zipkey/batch.go
index ebbd081..85d1d35 100644
--- a/skate/zipkey/batch.go
+++ b/skate/zipkey/batch.go
@@ -19,9 +19,14 @@ type Batcher struct {
// NewBatcher set ups a new Batcher.
func NewBatcher(gf groupFunc) *Batcher {
+ return NewBatcherSize(gf, 1000)
+}
+
+// NewBatcherSize initializes a batcher with a given size.
+func NewBatcherSize(gf groupFunc, size int) *Batcher {
batcher := Batcher{
gf: gf,
- Size: 1000,
+ Size: size,
NumWorkers: runtime.NumCPU(),
queue: make(chan []*Group),
}
@@ -46,7 +51,7 @@ func (b *Batcher) Close() error {
}
// GroupFunc implement the groupFunc type. Not thread safe. Panics if called
-// after Close has been called.
+// after Close.
func (b *Batcher) GroupFunc(g *Group) error {
if b.closing {
panic("cannot call GroupFunc after Close")