Skip to content

iotopo/batch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

batch

golang asynchronous batch writer

Quickstart

# make sure you have go1.18 or higher

# install library
go get -u github.com/iotopo/batch

example

package main

import (
	"fmt"
	"time"

	"github.com/iotopo/batch"
)

func main() {
	writer := batch.NewBatchWriter(10, 1 * time.Second, func (items []int)  {
		fmt.Println("need to write:", len(items))
	})

	for i := 0; i < 100; i++ {
		writer.AppendData(i)
		time.Sleep(100 * time.Millisecond)
	}
}

About

golang asynchronous batch writer

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages