Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hammer ¶
type Hammer struct { *shutter.Shutter In chan interface{} Out chan interface{} // contains filtered or unexported fields }
Hammer is a tool that batches and parallelize tasks from the 'In' channel and writes results to the 'Out' channel. It can optimize performance in two ways:
- It calls your HammerFunc with a maximum of `batchSize` values taken from the 'In' channel (batching)
- It calls your HammerFunc a maximum of `maxConcurrency` times in parallel (debouncing)
Both approaches give good results, but combining them gives greatest results, especially with large batch size with small debouncing.
Closing the context will shutdown the batcher immediately. calling "Close" will close the `In` chan and finish processing until the Hammer closes the `Out` chan and shuts down
func NewHammer ¶
func NewHammer(batchSize, maxConcurrency int, hammerFunc HammerFunc, options ...HammerOption) *Hammer
NewHammer returns a single-use batcher startSingle will force batcher to run the first batch with a single object in it
type HammerFunc ¶
type HammerOption ¶
type HammerOption = func(h *Hammer)
func FirstBatchUnitary ¶
func FirstBatchUnitary() HammerOption
func HammerLogger ¶
func HammerLogger(logger *zap.Logger) HammerOption
func SetInChanSize ¶
func SetInChanSize(size int) HammerOption
type Nailer ¶
type Nailer struct { *shutter.Shutter In chan interface{} Out chan interface{} // contains filtered or unexported fields }
func NewNailer ¶
func NewNailer(maxConcurrency int, nailerFunc NailerFunc, options ...NailerOption) *Nailer
func (*Nailer) WaitUntilEmpty ¶
WaitUntilEmpty waits until no more input nor active inflight operations is in progress blocking the current goroutine along the way. The output must be consumed for this method to work. You should use `NailerDiscardall()` option if you don't care about the output.
**Important** You are responsible of ensuring that no new inputs are being push while waiting. This method does not protect against such case right now and could unblock just before a new input is pushed which would make the instance "non-emtpy" anymore.
type NailerFunc ¶
type NailerOption ¶
type NailerOption = func(h *Nailer)
func NailerDiscardAll ¶
func NailerDiscardAll() NailerOption
func NailerLogger ¶
func NailerLogger(logger *zap.Logger) NailerOption