Documentation ¶
Overview ¶
Package roxyutil provides miscellaneous utility functions for use by Roxy and by users of mainutil.
As with mainutil, it is undecided how much (if any) of the roxyutil API will remain available outside of the Roxy project once Roxy reaches v1.0.0.
Index ¶
- Variables
- func Assert(cond bool, message string)
- func AssertNotNil(v interface{})
- func Assertf(cond bool, format string, v ...interface{})
- func ExpandPassword(in string) (string, error)
- func ExpandPath(in string) (string, error)
- func ExpandPathWithCWD(in string, cwd string) (string, error)
- func ExpandString(in string) (string, error)
- func LookupGroupByID(gid uint32) (*user.Group, error)
- func LookupGroupByName(groupName string) (*user.Group, error)
- func LookupHost(ctx context.Context, res *net.Resolver, hostname string) ([]net.IP, error)
- func LookupPort(ctx context.Context, res *net.Resolver, network string, service string) (uint16, error)
- func LookupSRV(ctx context.Context, res *net.Resolver, service, network, domain string) (string, []*net.SRV, error)
- func LookupUserByID(uid uint32) (*user.User, error)
- func LookupUserByName(userName string) (*user.User, error)
- func MakeAllowedEnumNames(enumData []EnumData) []string
- func MarshalEnumToJSON(enumName string, enumData []EnumData, value uint) ([]byte, error)
- func ParseEnum(enumName string, enumData []EnumData, str string) (uint, error)
- func PathAbs(str string) (string, error)
- func UnmarshalEnumFromJSON(enumName string, enumData []EnumData, raw []byte) (uint, error)
- func ValidateATCLocation(str string) error
- func ValidateATCServiceName(str string) error
- func ValidateATCUniqueID(str string) error
- func ValidateEtcdPath(str string) error
- func ValidateNamedPort(str string) error
- func ValidateZKPath(str string) error
- type ATCLoadUniqueError
- type ATCLocationError
- type ATCServiceNameError
- type ATCShardNumberError
- type ATCUniqueIDError
- type AuthorityError
- type BoolError
- type CheckError
- type EndpointError
- type EnumData
- type EnvVarLookupError
- type ExpectLiteralError
- type GRPCStatusError
- type HostError
- type HostPortError
- type IPError
- type InvalidEnumNameError
- type InvalidEnumValueError
- type ListIndexError
- type LookupGroupByIDError
- type LookupGroupByNameError
- type LookupHostError
- type LookupPortError
- type LookupSRVError
- type LookupUserByIDError
- type LookupUserByNameError
- type MapKeyError
- type PathAbsError
- type PathError
- type PortError
- type PortType
- type QueryParamError
- type QueryStringError
- type RegexpMatchError
- type SchemeError
- type StructFieldError
Constants ¶
This section is empty.
Variables ¶
var ( ErrFailedToMatch = inputError("failed to match expected pattern") ErrExpectEmpty = inputError("expected empty string") ErrExpectEmptyOrLocalhost = inputError("expected empty string or \"localhost\"") ErrExpectNonEmpty = inputError("expected non-empty string") ErrExpectOneSlash = inputError("expected one '/', found 2 or more") ErrExpectLeadingSlash = inputError("expected path to start with '/'") ErrExpectTrailingSlash = inputError("expected path to end with '/'") ErrExpectNoEndSlash = inputError("did not expect path to end with '/'") ErrExpectNoDoubleSlash = inputError("did not expect path to contain '//'") ErrExpectNoDot = inputError("did not expect path to contain '/./'") ErrExpectNoDotDot = inputError("did not expect path to contain '/../'") ErrExpectEmptyList = inputError("expected empty list") ErrExpectNonEmptyList = inputError("expected non-empty list") )
ErrFailedToMatch et al signal that input parsing has failed.
var ErrIsNull = isNullError(0)
ErrIsNull indicates that a JSON null value was parsed.
var ErrNoHealthyBackends = noHealthyBackendsError(0)
ErrNoHealthyBackends signals that a roxyresolver.Resolver was unable to find any healthy servers to talk to.
var ErrNotExist = notExistError(0)
ErrNotExist signals that something does not exist.
Functions ¶
func AssertNotNil ¶ added in v0.5.0
func AssertNotNil(v interface{})
AssertNotNil takes a pointer to a nil-able type (pointer, interface, etc) and panics with CheckError if the pointed-to value is nil.
func ExpandPassword ¶
ExpandPassword expands ${ENV_VAR} references and @file references.
func ExpandPath ¶
ExpandPath expands ${ENV_VAR} references, ~ and ~user references, and makes the path absolute (by assuming it is relative to the current directory).
func ExpandPathWithCWD ¶ added in v0.4.8
ExpandPathWithCWD expands ${ENV_VAR} references, ~ and ~user references, and makes the path absolute (by assuming it is relative to the given cwd).
func ExpandString ¶
ExpandString expands ${ENV_VAR} references.
func LookupGroupByID ¶ added in v0.4.6
LookupGroupByID is a wrapper around "os/user".LookupGroupId.
func LookupGroupByName ¶ added in v0.4.6
LookupGroupByName is a wrapper around "os/user".LookupGroup.
func LookupHost ¶ added in v0.4.7
LookupHost is a wrapper around "net".(*Resolver).LookupHost.
func LookupPort ¶ added in v0.4.7
func LookupPort(ctx context.Context, res *net.Resolver, network string, service string) (uint16, error)
LookupPort is a wrapper around "net".(*Resolver).LookupPort.
func LookupSRV ¶ added in v0.4.7
func LookupSRV(ctx context.Context, res *net.Resolver, service, network, domain string) (string, []*net.SRV, error)
LookupSRV is a wrapper around "net".(*Resolver).LookupSRV.
func LookupUserByID ¶ added in v0.4.6
LookupUserByID is a wrapper around "os/user".LookupId.
func LookupUserByName ¶ added in v0.4.6
LookupUserByName is a wrapper around "os/user".Lookup.
func MakeAllowedEnumNames ¶ added in v0.4.7
MakeAllowedEnumNames returns the list of canonical string representations for this enum.
func MarshalEnumToJSON ¶ added in v0.4.7
MarshalEnumToJSON marshals this enum value to JSON. It may panic with InvalidEnumValueError if the enum value is out of range.
func ParseEnum ¶ added in v0.4.7
ParseEnum parses an enum value. Returns InvalidEnumNameError if the string cannot be parsed.
func UnmarshalEnumFromJSON ¶ added in v0.4.7
UnmarshalEnumFromJSON unmarshals an enum value from JSON. Returns ErrIsNull, InvalidEnumNameError, or InvalidEnumValueError if a JSON value was parsed but could not be unmarshaled as an enum value.
func ValidateATCLocation ¶
ValidateATCLocation validates that the given string is a valid Location for the Air Traffic Control service.
func ValidateATCServiceName ¶
ValidateATCServiceName validates that the given string is a valid Service Name for the Air Traffic Control service.
func ValidateATCUniqueID ¶ added in v0.6.0
ValidateATCUniqueID validates that the given string is a valid UniqueID for the Air Traffic Control service.
func ValidateEtcdPath ¶
ValidateEtcdPath validates that the given string is a valid etcd.io V3 key prefix, which must end with a "/".
func ValidateNamedPort ¶
ValidateNamedPort validates that the given string is a valid named port for a membership.Roxy or membership.ServerSet address advertisement.
func ValidateZKPath ¶
ValidateZKPath validates that the given string is a valid ZooKeeper node path.
Types ¶
type ATCLoadUniqueError ¶ added in v0.6.0
type ATCLoadUniqueError struct {
Err error
}
ATCLoadUniqueError represents failure to load or persist a stable unique ID.
func (ATCLoadUniqueError) Error ¶ added in v0.6.0
func (err ATCLoadUniqueError) Error() string
Error fulfills the error interface.
func (ATCLoadUniqueError) Unwrap ¶ added in v0.6.0
func (err ATCLoadUniqueError) Unwrap() error
Unwrap returns the underlying cause of this error.
type ATCLocationError ¶ added in v0.4.6
ATCLocationError represents failure to parse an ATC location.
func (ATCLocationError) Error ¶ added in v0.4.6
func (err ATCLocationError) Error() string
Error fulfills the error interface.
func (ATCLocationError) Unwrap ¶ added in v0.4.6
func (err ATCLocationError) Unwrap() error
Unwrap returns the underlying cause of this error.
type ATCServiceNameError ¶ added in v0.4.6
ATCServiceNameError represents failure to parse an ATC service name.
func (ATCServiceNameError) Error ¶ added in v0.4.6
func (err ATCServiceNameError) Error() string
Error fulfills the error interface.
func (ATCServiceNameError) Unwrap ¶ added in v0.4.6
func (err ATCServiceNameError) Unwrap() error
Unwrap returns the underlying cause of this error.
type ATCShardNumberError ¶ added in v0.6.0
ATCShardNumberError represents failure to parse an ATC shard number.
func (ATCShardNumberError) Error ¶ added in v0.6.0
func (err ATCShardNumberError) Error() string
Error fulfills the error interface.
func (ATCShardNumberError) Unwrap ¶ added in v0.6.0
func (err ATCShardNumberError) Unwrap() error
Unwrap returns the underlying cause of this error.
type ATCUniqueIDError ¶ added in v0.6.0
ATCUniqueIDError represents failure to parse an ATC unique ID.
func (ATCUniqueIDError) Error ¶ added in v0.6.0
func (err ATCUniqueIDError) Error() string
Error fulfills the error interface.
func (ATCUniqueIDError) Unwrap ¶ added in v0.6.0
func (err ATCUniqueIDError) Unwrap() error
Unwrap returns the underlying cause of this error.
type AuthorityError ¶ added in v0.4.6
AuthorityError represents failure to parse a URL authority section or a Target authority section.
func (AuthorityError) Error ¶ added in v0.4.6
func (err AuthorityError) Error() string
Error fulfills the error interface.
func (AuthorityError) Unwrap ¶ added in v0.4.6
func (err AuthorityError) Unwrap() error
Unwrap returns the underlying cause of this error.
type BoolError ¶ added in v0.4.6
BoolError represents failure to parse the string representation of a boolean value.
type CheckError ¶ added in v0.4.7
type CheckError struct {
Message string
}
CheckError represents an assertion failure.
func (CheckError) Error ¶ added in v0.4.7
func (err CheckError) Error() string
Error fulfills the error interface.
type EndpointError ¶ added in v0.4.6
EndpointError represents failure to parse a Target endpoint section.
func (EndpointError) Error ¶ added in v0.4.6
func (err EndpointError) Error() string
Error fulfills the error interface.
func (EndpointError) Unwrap ¶ added in v0.4.6
func (err EndpointError) Unwrap() error
Unwrap returns the underlying cause of this error.
type EnumData ¶ added in v0.4.7
type EnumData struct { // GoName is the Go constant name for this enum value. GoName string // Name is the string representation of this enum value. Name string // JSON is the JSON representation of this enum value. // // Optional; it is inferred from Name if not set. JSON []byte // Aliases is a list of zero or more aliases for this enum value. // // Optional. Aliases []string }
EnumData holds data about one particular enum value.
type EnvVarLookupError ¶ added in v0.4.6
EnvVarLookupError represents failure to look up an environment variable.
func (EnvVarLookupError) Error ¶ added in v0.4.6
func (err EnvVarLookupError) Error() string
Error fulfills the error interface.
func (EnvVarLookupError) Unwrap ¶ added in v0.4.6
func (err EnvVarLookupError) Unwrap() error
Unwrap returns the underlying cause of this error.
type ExpectLiteralError ¶ added in v0.4.7
type ExpectLiteralError string
ExpectLiteralError represents failure to parse an input.
func (ExpectLiteralError) Error ¶ added in v0.4.7
func (err ExpectLiteralError) Error() string
Error fulfills the error interface.
func (ExpectLiteralError) GRPCStatusCode ¶ added in v0.4.7
func (err ExpectLiteralError) GRPCStatusCode() codes.Code
GRPCStatusCode returns the GRPC status code "InvalidArgument".
type GRPCStatusError ¶ added in v0.4.6
GRPCStatusError represents an error with an associated GRPC status code.
func MakeGRPCStatusError ¶ added in v0.4.6
func MakeGRPCStatusError(err error) GRPCStatusError
MakeGRPCStatusError attempts to autodetect the correct status code.
func (GRPCStatusError) Error ¶ added in v0.4.6
func (err GRPCStatusError) Error() string
Error fulfills the error interface.
func (GRPCStatusError) GRPCStatus ¶ added in v0.4.6
func (err GRPCStatusError) GRPCStatus() *status.Status
GRPCStatus returns this error's representation as a gRPC Status.
func (GRPCStatusError) Unwrap ¶ added in v0.4.6
func (err GRPCStatusError) Unwrap() error
Unwrap returns the underlying cause of this error.
type HostError ¶ added in v0.4.6
HostError represents failure to parse a hostname string.
type HostPortError ¶ added in v0.4.6
HostPortError represents failure to parse a "host:port"-shaped string.
func (HostPortError) Error ¶ added in v0.4.6
func (err HostPortError) Error() string
Error fulfills the error interface.
func (HostPortError) Unwrap ¶ added in v0.4.6
func (err HostPortError) Unwrap() error
Unwrap returns the underlying cause of this error.
type IPError ¶ added in v0.4.6
IPError represents failure to parse an IP address string.
type InvalidEnumNameError ¶ added in v0.4.7
InvalidEnumNameError indicates an enum whose string representation could not be recognized.
func (InvalidEnumNameError) Error ¶ added in v0.4.7
func (err InvalidEnumNameError) Error() string
Error fulfills the error interface.
type InvalidEnumValueError ¶ added in v0.4.7
InvalidEnumValueError indicates an enum whose numeric value is out of range.
func (InvalidEnumValueError) Error ¶ added in v0.4.7
func (err InvalidEnumValueError) Error() string
Error fulfills the error interface.
type ListIndexError ¶ added in v0.4.7
ListIndexError indicates an error in one item of a list.
func (ListIndexError) Error ¶ added in v0.4.7
func (err ListIndexError) Error() string
Error fulfills the error interface.
func (ListIndexError) Unwrap ¶ added in v0.4.7
func (err ListIndexError) Unwrap() error
Unwrap returns the underlying cause of this error.
type LookupGroupByIDError ¶ added in v0.4.6
LookupGroupByIDError represents failure to look up an OS group by GID.
func (LookupGroupByIDError) Error ¶ added in v0.4.6
func (err LookupGroupByIDError) Error() string
Error fulfills the error interface.
func (LookupGroupByIDError) Unwrap ¶ added in v0.4.6
func (err LookupGroupByIDError) Unwrap() error
Unwrap returns the underlying cause of this error.
type LookupGroupByNameError ¶ added in v0.4.6
LookupGroupByNameError represents failure to look up an OS group by name.
func (LookupGroupByNameError) Error ¶ added in v0.4.6
func (err LookupGroupByNameError) Error() string
Error fulfills the error interface.
func (LookupGroupByNameError) Unwrap ¶ added in v0.4.6
func (err LookupGroupByNameError) Unwrap() error
Unwrap returns the underlying cause of this error.
type LookupHostError ¶ added in v0.4.7
LookupHostError represents failure to look up DNS A/AAAA records.
func (LookupHostError) Error ¶ added in v0.4.7
func (err LookupHostError) Error() string
Error fulfills the error interface.
func (LookupHostError) Unwrap ¶ added in v0.4.7
func (err LookupHostError) Unwrap() error
Unwrap returns the underlying cause of this error.
type LookupPortError ¶ added in v0.4.7
LookupPortError represents failure to look up a network port by service name, using /etc/services or the like.
func (LookupPortError) Error ¶ added in v0.4.7
func (err LookupPortError) Error() string
Error fulfills the error interface.
func (LookupPortError) Unwrap ¶ added in v0.4.7
func (err LookupPortError) Unwrap() error
Unwrap returns the underlying cause of this error.
type LookupSRVError ¶ added in v0.4.7
LookupSRVError represents failure to look up DNS SRV records.
func (LookupSRVError) Error ¶ added in v0.4.7
func (err LookupSRVError) Error() string
Error fulfills the error interface.
func (LookupSRVError) Unwrap ¶ added in v0.4.7
func (err LookupSRVError) Unwrap() error
Unwrap returns the underlying cause of this error.
type LookupUserByIDError ¶ added in v0.4.6
LookupUserByIDError represents failure to look up an OS user by UID.
func (LookupUserByIDError) Error ¶ added in v0.4.6
func (err LookupUserByIDError) Error() string
Error fulfills the error interface.
func (LookupUserByIDError) Unwrap ¶ added in v0.4.6
func (err LookupUserByIDError) Unwrap() error
Unwrap returns the underlying cause of this error.
type LookupUserByNameError ¶ added in v0.4.6
LookupUserByNameError represents failure to look up an OS user by name.
func (LookupUserByNameError) Error ¶ added in v0.4.6
func (err LookupUserByNameError) Error() string
Error fulfills the error interface.
func (LookupUserByNameError) Unwrap ¶ added in v0.4.6
func (err LookupUserByNameError) Unwrap() error
Unwrap returns the underlying cause of this error.
type MapKeyError ¶ added in v0.4.7
MapKeyError indicates an error in one value of a map.
func (MapKeyError) Error ¶ added in v0.4.7
func (err MapKeyError) Error() string
Error fulfills the error interface.
func (MapKeyError) Unwrap ¶ added in v0.4.7
func (err MapKeyError) Unwrap() error
Unwrap returns the underlying cause of this error.
type PathAbsError ¶ added in v0.4.6
PathAbsError represents failure to make a file path absolute.
func (PathAbsError) Error ¶ added in v0.4.6
func (err PathAbsError) Error() string
Error fulfills the error interface.
func (PathAbsError) Unwrap ¶ added in v0.4.6
func (err PathAbsError) Unwrap() error
Unwrap returns the underlying cause of this error.
type PathError ¶ added in v0.4.6
PathError represents failure to parse a path of some sort, such as a URL path or a ZooKeeper path.
type PortError ¶ added in v0.4.6
PortError represents failure to parse a port number string.
type PortType ¶ added in v0.4.7
type PortType uint8
PortType denotes whether a port is named, numbered, or either.
type QueryParamError ¶ added in v0.4.6
QueryParamError represents failure to parse the value of a specific URL query parameter or a specific Target query parameter.
func (QueryParamError) Error ¶ added in v0.4.6
func (err QueryParamError) Error() string
Error fulfills the error interface.
func (QueryParamError) Unwrap ¶ added in v0.4.6
func (err QueryParamError) Unwrap() error
Unwrap returns the underlying cause of this error.
type QueryStringError ¶ added in v0.4.6
QueryStringError represents failure to parse a URL query string or a Target query string.
func (QueryStringError) Error ¶ added in v0.4.6
func (err QueryStringError) Error() string
Error fulfills the error interface.
func (QueryStringError) Unwrap ¶ added in v0.4.6
func (err QueryStringError) Unwrap() error
Unwrap returns the underlying cause of this error.
type RegexpMatchError ¶ added in v0.4.6
RegexpMatchError represents failure to match a regular expression.
func (RegexpMatchError) Error ¶ added in v0.4.6
func (err RegexpMatchError) Error() string
Error fulfills the error interface.
func (RegexpMatchError) GRPCStatusCode ¶ added in v0.4.6
func (err RegexpMatchError) GRPCStatusCode() codes.Code
GRPCStatusCode returns the GRPC status code "InvalidArgument".
type SchemeError ¶ added in v0.4.6
SchemeError represents failure to identify a URL scheme or a Target scheme.
func (SchemeError) Error ¶ added in v0.4.6
func (err SchemeError) Error() string
Error fulfills the error interface.
func (SchemeError) Unwrap ¶ added in v0.4.6
func (err SchemeError) Unwrap() error
Unwrap returns the underlying cause of this error.
type StructFieldError ¶ added in v0.4.7
StructFieldError indicates an error in one field of a struct.
func (StructFieldError) Error ¶ added in v0.4.7
func (err StructFieldError) Error() string
Error fulfills the error interface.
func (StructFieldError) Unwrap ¶ added in v0.4.7
func (err StructFieldError) Unwrap() error
Unwrap returns the underlying cause of this error.