// New creates a new ErrBag, for safety purpose. waitTime corresponds to the
// number of seconds to wait when the error rate threshold is reached.
// errBagSize is, in seconds, the size of the sliding window to consider
// for throttling. You can see it as the size of the errbag. The larger it is,
// the larger the window to consider for error rate is. Consider this value
// along with leakInterval. leakInterval corresponds to the time to wait,
// in milliseconds, before an error is discarded from the errbag. It must be
// equal or greater than 100, otherwise throttling will be ineffective.
New creates a new ErrBag, for safety purpose. waitTime corresponds to the
number of seconds to wait when the error rate threshold is reached.
errBagSize is, in seconds, the size of the sliding window to consider
for throttling. You can see it as the size of the errbag. The larger it is,
the larger the window to consider for error rate is. Consider this value
along with leakInterval. leakInterval corresponds to the time to wait,
in milliseconds, before an error is discarded from the errbag. It must be
equal or greater than 100, otherwise throttling will be ineffective.
// New creates a new ErrBag for safety purpose . waitTime corresponds to the // number of seconds to wait when the error rate threshold is reached . // errBagSize is in seconds the size of the sliding window to consider // for throttling . You can see it as the size of the errbag . The larger it is // the larger the window to consider for error rate is . Consider this value // along with leakInterval . leakInterval corresponds to the time to wait // in milliseconds before an error is discarded from the errbag . It must be // equal or greater than 100 otherwise throttling will be ineffective .
func New(waitTime, errBagSize, leakInterval uint) (*ErrBag, error) {
	if waitTime == 0 {
		return nil, errors.New("setting waitTime to 0 would prevent throttling")
	}
	if errBagSize == 0 {
		return nil, errors.New("setting errBagSize to 0 would prevent throttling")
	}
	if leakInterval < 100 {
		return nil, errors.New("leakInterval must be greater than 100")
	}
	errChan := make(chan struct{}, errBagSize)
	done := make(chan struct{}, 1)
	return &ErrBag{waitTime: waitTime, leakInterval: leakInterval, errChan: errChan, done: done}, nil
}
func New ( waitTime , errBagSize , leakInterval uint ) ( * ErrBag , error ) { if waitTime == 0 { return nil , errors . New ( " " ) } if errBagSize == 0 { return nil , errors . New ( " " ) } if leakInterval < 100 { return nil , errors . New ( " " ) } errChan := make ( chan struct { } , errBagSize ) done := make ( chan struct { } , 1 ) return & ErrBag { waitTime : waitTime , leakInterval : leakInterval , errChan : errChan , done : done } , nil }
New creates a new ErrBag, for safety purpose.
New creates a new ErrBag for safety purpose .
// channels are closed when Deflate() is invoked