// Record records an error if its value is non nil. It shall be called
// by any function returning an error in order to properly rate limit the
// errors produced. RecordError will wait for waitTime seconds if the error
// rate is too high.
// callback purpose is for the caller to be informed about the errbag status
// after an error has been recorded in order to help take the appropriate
// actions. nil can be passed if the caller is not interested in the status.
// Note that record will panic if called after Deflate() has been called.
Record records an error if its value is non nil. It shall be called
by any function returning an error in order to properly rate limit the
errors produced. RecordError will wait for waitTime seconds if the error
rate is too high.
callback purpose is for the caller to be informed about the errbag status
after an error has been recorded in order to help take the appropriate
actions. nil can be passed if the caller is not interested in the status.
Note that record will panic if called after Deflate() has been called.
// Record records an error if its value is non nil . It shall be called // by any function returning an error in order to properly rate limit the // errors produced . RecordError will wait for waitTime seconds if the error // rate is too high . // callback purpose is for the caller to be informed about the errbag status // after an error has been recorded in order to help take the appropriate // actions . nil can be passed if the caller is not interested in the status . // Note that record will panic if called after Deflate () has been called .
func (eb ErrBag) Record(err error, callback CallbackFunc) {
	if err != nil {
		select {
		case eb.errChan <- struct{}{}:
			if callback != nil {
				callback(Status{State: StatusOK})
			}
		default:
			if callback != nil {
				callback(Status{State: StatusThrottling, WaitTime: eb.waitTime})
			}
			time.Sleep(time.Second * time.Duration(eb.waitTime))
		}
	}
}
func ( eb ErrBag ) Record ( err error , callback CallbackFunc ) { if err != nil { select { case eb . errChan <- struct { } { } : if callback != nil { callback ( Status { State : StatusOK } ) } default : if callback != nil { callback ( Status { State : StatusThrottling , WaitTime : eb . waitTime } ) } time . Sleep ( time . Second * time . Duration ( eb . waitTime ) ) } } }
Record records an error if its value is non nil.
Record records an error if its value is non nil .