coalescer

package module
v0.0.0-...-0e372ad Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2014 License: MIT Imports: 3 Imported by: 0

README

coalescer

A Bolt transaction coalescer.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRollback is returned from Update() when a future transaction in the
	// same coalescing group returns an error and rolls back the transaction.
	ErrRollback = errors.New("rollback")

	// ErrInvalidLimit is returned when the limit passed to New() is
	// a non-positive integer.
	ErrInvalidLimit = errors.New("invalid coalescer limit")

	// ErrInvalidInterval is returned when the interval passed to New() is
	// a non-positive duration.
	ErrInvalidInterval = errors.New("invalid coalescer interval")
)

Functions

This section is empty.

Types

type Coalescer

type Coalescer struct {
	// contains filtered or unexported fields
}

Coalescer automatically groups together Bolt write transactions and flushes them together as a single transaction. This approach is useful for increasing write throughput. However, because all transactions are grouped together, rolling back one transaction will roll back all of them.

func New

func New(db *bolt.DB, limit int, interval time.Duration) (*Coalescer, error)

New returns a new transaction Coalescer for a Bolt database. The coalescer will automatically flush when the number of transactions reaches the limit or after the interval has passed. If limit or interval is zero then those parameters are ignored.

func (*Coalescer) Update

func (c *Coalescer) Update(fn func(tx *bolt.Tx) error) error

Update executes a function in the context of a write transaction.

Jump to

Keyboard shortcuts

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