github.com/haraldrudell/parl@v0.4.176/internal/cyclebreaker/err-end-callbacks.go (about) 1 /* 2 © 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/) 3 ISC License 4 */ 5 6 package cyclebreaker 7 8 import ( 9 "errors" 10 ) 11 12 // ErrEndCallbacks indicates upon retun from a callback function that 13 // no more callbacks are desired. It does not indicate an error and is not returned 14 // as an error by any other function than the callback. 15 // 16 // callback invocations may be thread-safe, re-entrant and panic-handling but 17 // this depends on the callback-invoking implementation used. 18 // 19 // Usage: 20 // 21 // if errors.Is(err, parl.ErrEndCallbacks) { … 22 var ErrEndCallbacks = EndCallbacks(errors.New("end callbacks error")) 23 24 func EndCallbacks(err error) (err2 error) { return &endCallbacks{err} } 25 26 type endCallbacks struct{ error } 27 28 func (ec *endCallbacks) Is(err error) (is bool) { 29 _, is = err.(interface{ EndCallbacks() }) 30 return 31 } 32 func (ec *endCallbacks) EndCallbacks() {}