Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorBuffer ¶
type ErrorBuffer struct {
// contains filtered or unexported fields
}
An ErrorBuffer is meant to make sure that something doesn't error out too much, too fast.
func NewErrorBuffer ¶
func NewErrorBuffer(maxCount uint, window time.Duration) *ErrorBuffer
NewErrorBuffer creates a new error buffer, that will accept up to maxCount errors in the given time window.
func (*ErrorBuffer) Add ¶
func (b *ErrorBuffer) Add(err error) error
Add adds an error to the buffer. If there have been too many errors (i.e. more than the buffer's maxCount) in too short a time (i.e. in the buffer's current sliding window), then it returns an error aggregating those; otherwise returns nil. This is not thread-safe.
Click to show internal directories.
Click to hide internal directories.