// DefaultErrHandler returns a Fail message if 8 errors have occurred in 4
// hours. Otherwise it enters the Sleep state for 10 minutes before trying
// again.
DefaultErrHandler returns a Fail message if 8 errors have occurred in 4
hours. Otherwise it enters the Sleep state for 10 minutes before trying
again.
// DefaultErrHandler returns a Fail message if 8 errors have occurred in 4 // hours . Otherwise it enters the Sleep state for 10 minutes before trying // again .
func DefaultErrHandler(_ metafora.Task, errs []Err) (*Message, []Err) {
	recent := time.Now().Add(DefaultErrLifetime)
	strikes := 0
	for _, err := range errs {
		if err.Time.After(recent) {
			strikes++
		}
	}
	if len(errs) > DefaultErrMax {
		errs = errs[len(errs)-DefaultErrMax:]
	}
	if strikes >= DefaultErrMax {
		return ErrorMessage(ExceededErrorRate), errs
	}
	return SleepMessage(time.Now().Add(10 * time.Minute)), errs
}
func DefaultErrHandler ( _ metafora . Task , errs [ ] Err ) ( * Message , [ ] Err ) { recent := time . Now ( ) . Add ( DefaultErrLifetime ) strikes := 0 for _ , err := range errs { if err . Time . After ( recent ) { strikes ++ } } if len ( errs ) > DefaultErrMax { errs = errs [ len ( errs ) - DefaultErrMax : ] } if strikes >= DefaultErrMax { return ErrorMessage ( ExceededErrorRate ) , errs } return SleepMessage ( time . Now ( ) . Add ( 10 * time . Minute ) ) , errs }
DefaultErrHandler returns a Fail message if 8 errors have occurred in 4
hours.
DefaultErrHandler returns a Fail message if 8 errors have occurred in 4 hours .
// Return a new error to transition to Failed as well as the original // errors to store what caused this failure.