go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/breaker/errors.go (about)

     1  package breaker
     2  
     3  import "go.charczuk.com/sdk/errutil"
     4  
     5  var (
     6  	// ErrTooManyRequests is returned when the CB state is half open and the requests count is over the cb maxRequests
     7  	ErrTooManyRequests errutil.Class = "too many requests"
     8  	// ErrOpenState is returned when the CB state is open
     9  	ErrOpenState errutil.Class = "circuit breaker is open"
    10  )
    11  
    12  // ErrIsOpen returns if the error is an ErrOpenState.
    13  func ErrIsOpen(err error) bool {
    14  	return errutil.Is(err, ErrOpenState)
    15  }
    16  
    17  // ErrIsTooManyRequests returns if the error is an ErrTooManyRequests.
    18  func ErrIsTooManyRequests(err error) bool {
    19  	return errutil.Is(err, ErrTooManyRequests)
    20  }