batch

package
v1.2.160 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2019 License: AGPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Committer

type Committer interface {
	Start()
	Queue(Value)
	Stop()
}

Committer commits items in a background thread

func NewCommitter

func NewCommitter(label string, db *sqlx.DB, sql string, timeout time.Duration, wg *sync.WaitGroup, callback ErrorCallback) Committer

NewCommitter creates a new committer that will commit items in batches as quickly as possible.

type ErrorCallback

type ErrorCallback func(err error, value Value)

ErrorCallback lets callers get a callback when a value fails to be committed

type Value

type Value interface {
	RowID() string
}

Value represents the interface values must satisfy. The RowID() method should return the unique row ID (if any) for the item. This will be used to make sure that no update is made on the same value in the same statement. (which would fail for bulk updates) Items which are being inserted may return an empty string for RowID()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL