github.com/blend/go-sdk@v1.20220411.3/breaker/errors.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package breaker 9 10 import "github.com/blend/go-sdk/ex" 11 12 var ( 13 // ErrTooManyRequests is returned when the CB state is half open and the requests count is over the cb maxRequests 14 ErrTooManyRequests ex.Class = "too many requests" 15 // ErrOpenState is returned when the CB state is open 16 ErrOpenState ex.Class = "circuit breaker is open" 17 ) 18 19 // ErrIsOpen returns if the error is an ErrOpenState. 20 func ErrIsOpen(err error) bool { 21 return ex.Is(err, ErrOpenState) 22 } 23 24 // ErrIsTooManyRequests returns if the error is an ErrTooManyRequests. 25 func ErrIsTooManyRequests(err error) bool { 26 return ex.Is(err, ErrTooManyRequests) 27 }