Documentation
¶
Overview ¶
Package mock provides a mock implementation of a batch handler.
Index ¶
- type Flusher
- func (f *Flusher[T]) BatchesFlushed() [][]T
- func (f *Flusher[T]) Block()
- func (f *Flusher[T]) BlockForDuration(duration int)
- func (f *Flusher[T]) FinishCount() int
- func (f *Flusher[T]) Flush(ctx context.Context, items []T)
- func (f *Flusher[T]) IsFlushingRightNow() bool
- func (f *Flusher[T]) SetIgnoreContextCancellation(d time.Duration)
- func (f *Flusher[T]) SetOnFlush(onFlush func(ctx context.Context, items []T))
- func (f *Flusher[T]) StartCount() int
- func (f *Flusher[T]) Unblock()
- func (f *Flusher[T]) WaitForTotalFinished(num int, timeout ...time.Duration) chan struct{}
- func (f *Flusher[T]) WaitForTotalStarted(num int, timeout ...time.Duration) chan struct{}
- func (f *Flusher[T]) WasInterrupted() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Flusher ¶
Flusher is a mock implementation of a batch handler. It exposes a block and unblock method to influence the flushing behavior.
func (*Flusher[T]) BatchesFlushed ¶
func (f *Flusher[T]) BatchesFlushed() [][]T
BatchesFlushed returns all batches that have been flushed.
func (*Flusher[T]) BlockForDuration ¶
BlockForDuration blocks the flusher for a given duration.
func (*Flusher[T]) FinishCount ¶
FinishCount returns the number of times the flush method has finished.
func (*Flusher[T]) Flush ¶
Flush is the handler for flushing items. In this mock implementation, it will block until all blockers are removed.
func (*Flusher[T]) IsFlushingRightNow ¶
IsFlushingRightNow returns whether the flusher is currently running.
func (*Flusher[T]) SetIgnoreContextCancellation ¶
SetIgnoreContextCancellation sets the time to wait for the flusher to finish before shutting down because of a context cancellation.
func (*Flusher[T]) SetOnFlush ¶
SetOnFlush sets a callback that is called when the flush method is called.
func (*Flusher[T]) StartCount ¶
StartCount returns the number of times the flush method has been called.
func (*Flusher[T]) WaitForTotalFinished ¶
WaitForTotalFinished returns a channel that is closed when the flusher has finished flushing a given number of times since the start of the flusher. If the flusher does not finish in the given timeout, a panic is triggered. By default the timeout is 1 second.
func (*Flusher[T]) WaitForTotalStarted ¶
WaitForTotalStarted returns a channel that is closed when the flusher has started flushing a given number of times since the start of the flusher. If the flusher does not start in the given timeout, a panic is triggered. By default the timeout is 1 second.
func (*Flusher[T]) WasInterrupted ¶
WasInterrupted returns whether the flush was interrupted due to a context cancellation.