Documentation
¶
Index ¶
Constants ¶
View Source
const ( // DefaultBatchSize represents the default value for the size of each batch. DefaultBatchSize = 10 // DefaultMaxWait represents the default value of the maximum waiting time for filling each batch. DefaultMaxWait = 1 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batch ¶
type Batch struct {
// Input represents the batch input channel.
Input chan<- interface{}
// Output represents the batch output channel.
Output <-chan []interface{}
// contains filtered or unexported fields
}
Batch represents the go-batch struct.
func New ¶ added in v1.1.0
func New(optionFuncs ...OptionFunc) *Batch
New creates a new go-batch instance.
type OptionFunc ¶ added in v1.1.0
type OptionFunc func(*Options)
OptionFunc defines type for Options setter function.
func WithMaxWait ¶
func WithMaxWait(maxWait time.Duration) OptionFunc
WithMaxWait sets the maximum waiting time for filling each batch.
func WithSize ¶ added in v1.1.0
func WithSize(size int) OptionFunc
WithSize sets the maximum number of items that can be in each batch.
type Options ¶ added in v1.1.0
type Options struct {
// Size specifies the maximum number of items that can be in a batch.
//
// Default: 10.
Size int
// MaxWait specifies the maximum waiting time for filling a batch.
//
// Default: 1 * time.Second.
MaxWait time.Duration
}
Options sets configuration options for the go-batch instance.
Click to show internal directories.
Click to hide internal directories.