2017-09-01 22:02:50 +00:00
|
|
|
package structs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
errNoLeader = "No cluster leader"
|
|
|
|
errNoDCPath = "No path to datacenter"
|
2019-09-03 15:46:24 +00:00
|
|
|
errDCNotAvailable = "Remote DC has no server currently reachable"
|
2017-09-01 22:02:50 +00:00
|
|
|
errNoServers = "No known Consul servers"
|
|
|
|
errNotReadyForConsistentReads = "Not ready to serve consistent reads"
|
|
|
|
errSegmentsNotSupported = "Network segments are not supported in this version of Consul"
|
|
|
|
errRPCRateExceeded = "RPC rate limit exceeded"
|
2019-01-07 14:39:23 +00:00
|
|
|
errServiceNotFound = "Service not found: "
|
2020-07-01 13:12:59 +00:00
|
|
|
errQueryNotFound = "Query not found"
|
2017-09-01 22:02:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ErrNoLeader = errors.New(errNoLeader)
|
|
|
|
ErrNoDCPath = errors.New(errNoDCPath)
|
|
|
|
ErrNoServers = errors.New(errNoServers)
|
|
|
|
ErrNotReadyForConsistentReads = errors.New(errNotReadyForConsistentReads)
|
|
|
|
ErrSegmentsNotSupported = errors.New(errSegmentsNotSupported)
|
|
|
|
ErrRPCRateExceeded = errors.New(errRPCRateExceeded)
|
2019-09-03 15:46:24 +00:00
|
|
|
ErrDCNotAvailable = errors.New(errDCNotAvailable)
|
2020-07-01 13:12:59 +00:00
|
|
|
ErrQueryNotFound = errors.New(errQueryNotFound)
|
2017-09-01 22:02:50 +00:00
|
|
|
)
|
|
|
|
|
2020-07-01 13:12:59 +00:00
|
|
|
func IsErrNoDCPath(err error) bool {
|
|
|
|
return err != nil && strings.Contains(err.Error(), errNoDCPath)
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsErrQueryNotFound(err error) bool {
|
|
|
|
return err != nil && strings.Contains(err.Error(), errQueryNotFound)
|
|
|
|
}
|
|
|
|
|
2017-10-10 22:19:50 +00:00
|
|
|
func IsErrNoLeader(err error) bool {
|
|
|
|
return err != nil && strings.Contains(err.Error(), errNoLeader)
|
|
|
|
}
|
|
|
|
|
2017-09-01 22:02:50 +00:00
|
|
|
func IsErrRPCRateExceeded(err error) bool {
|
2017-10-10 22:19:50 +00:00
|
|
|
return err != nil && strings.Contains(err.Error(), errRPCRateExceeded)
|
2017-09-01 22:02:50 +00:00
|
|
|
}
|
2019-01-07 14:39:23 +00:00
|
|
|
|
|
|
|
func IsErrServiceNotFound(err error) bool {
|
|
|
|
return err != nil && strings.Contains(err.Error(), errServiceNotFound)
|
|
|
|
}
|