Documentation
¶
Index ¶
- Constants
- Variables
- func NoOpProcessor[T any]([]T) error
- func ProvideBatcherInFX[T any](processorFactory any, batchSize int, batchInterval time.Duration) fx.Option
- type AtomicCounter
- type Batcher
- func (b *Batcher[T]) Add(item T)
- func (b *Batcher[T]) Close() error
- func (b *Batcher[T]) Config() *Config[T]
- func (b *Batcher[T]) Errors() <-chan error
- func (b *Batcher[T]) IsClosed() bool
- func (b *Batcher[T]) Join(timeout time.Duration) error
- func (b *Batcher[T]) Len() int
- func (b *Batcher[T]) Start()
- type Config
- type Option
- type Processor
Constants ¶
View Source
const ( // DefaultBatchSize is the default batch size. DefaultBatchSize = 1000 // DefaultBatchInterval is the default batch interval. DefaultBatchInterval = 1 * time.Second // DefaultConcurrency is the default concurrency. DefaultConcurrency = 3 )
Variables ¶
View Source
var ErrTimeout = fmt.Errorf("timeout waiting for batches to complete")
Functions ¶
func NoOpProcessor ¶
Types ¶
type AtomicCounter ¶
type AtomicCounter struct {
// contains filtered or unexported fields
}
func NewAtomicCounter ¶
func NewAtomicCounter() *AtomicCounter
func (*AtomicCounter) Add ¶
func (c *AtomicCounter) Add(num int64)
func (*AtomicCounter) Read ¶
func (c *AtomicCounter) Read() int64
func (*AtomicCounter) Reset ¶
func (c *AtomicCounter) Reset()
type Batcher ¶
type Batcher[T any] struct { // contains filtered or unexported fields }
type Option ¶
func WithBatchInterval ¶
WithBatchInterval sets the batch interval.
func WithBatchSize ¶
WithBatchSize sets the batch size.
func WithProcessor ¶
WithProcessor sets the processor function to be called for each batch.
func WithSkipAutoStart ¶ added in v0.2.0
WithSkipAutoStart skips the automatic start of the batcher.
Click to show internal directories.
Click to hide internal directories.