2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
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 00:49:13 +00:00
|
|
|
errQueryNotFound = "Query not found"
|
2021-01-04 19:05:23 +00:00
|
|
|
errLeaderNotTracked = "Raft leader not found in server lookup mapping"
|
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 00:49:13 +00:00
|
|
|
ErrQueryNotFound = errors.New(errQueryNotFound)
|
2021-01-04 19:05:23 +00:00
|
|
|
ErrLeaderNotTracked = errors.New(errLeaderNotTracked)
|
2017-09-01 22:02:50 +00:00
|
|
|
)
|
|
|
|
|
2020-06-30 22:03:31 +00:00
|
|
|
func IsErrNoDCPath(err error) bool {
|
|
|
|
return err != nil && strings.Contains(err.Error(), errNoDCPath)
|
|
|
|
}
|
|
|
|
|
2020-07-01 00:49:13 +00:00
|
|
|
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)
|
|
|
|
}
|