Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test case for internal/errors/grpc.go #903

Merged
merged 9 commits into from
Jan 8, 2021
13 changes: 7 additions & 6 deletions hack/license/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@ var (
)

type Data struct {
Escape string
Escape string
Maintainer string
Year int
Year int
}

const (
defaultMaintainer = "vdaas.org vald team <[email protected]>"
maintainerKey = "MAINTAINER"
defaultMaintainer = "vdaas.org vald team <[email protected]>"
maintainerKey = "MAINTAINER"
)

func main() {
if len(os.Args) < 2 {
log.Fatal(errors.New("invalid argument"))
Expand Down Expand Up @@ -171,8 +172,8 @@ func readAndRewrite(path string) error {
}
d := Data{
Maintainer: maintainer,
Year: time.Now().Year(),
Escape: sharpEscape,
Year: time.Now().Year(),
Escape: sharpEscape,
}
if fi.Name() == "LICENSE" {
err = license.Execute(buf, d)
Expand Down
12 changes: 9 additions & 3 deletions internal/errors/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,39 @@ package errors

var (

// gRPC

ErrgRPCClientConnectionClose = func(name string, err error) error {
// ErrGRPCClientConnectionClose represents a function to generate an error that the gRPC connection couldn't close.
ErrGRPCClientConnectionClose = func(name string, err error) error {
return Wrapf(err, "%s's gRPC connection close error", name)
}

// ErrInvalidGRPCPort represents a function to generate an error that the gRPC port is invalid.
ErrInvalidGRPCPort = func(addr, host string, port uint16) error {
return Errorf("invalid gRPC client connection port to addr: %s,\thost: %s\t port: %d", addr, host, port)
}

// ErrInvalidGRPCClientConn represents a function to generate an error that the vald internal gRPC connection is invalid.
hlts2 marked this conversation as resolved.
Show resolved Hide resolved
ErrInvalidGRPCClientConn = func(addr string) error {
return Errorf("invalid gRPC client connection to %s", addr)
}

// ErrGRPCLookupIPAddrNotFound represents a function to generate an error that the vald internal gRPC client couldn't find IP address.
hlts2 marked this conversation as resolved.
Show resolved Hide resolved
ErrGRPCLookupIPAddrNotFound = func(host string) error {
return Errorf("vald internal gRPC client could not find ip addrs for %s", host)
}

// ErrGRPCClientNotFound represents an error that the vald internal gRPC client couldn't find.
ErrGRPCClientNotFound = New("vald internal gRPC client not found")

// ErrGRPCClientConnNotFound represents a function to generate an error that the gRPC client connection couldn't find.
ErrGRPCClientConnNotFound = func(addr string) error {
return Errorf("gRPC client connection not found in %s", addr)
}

// ErrRPCCallFailed represents a function to generate an error that the RPC call failed.
ErrRPCCallFailed = func(addr string, err error) error {
return Wrapf(err, "addr: %s", addr)
}

// ErrGRPCTargetAddrNotFound represents an error that the gRPC target address couldn't find.
ErrGRPCTargetAddrNotFound = New("grpc connection target not found")
)
Loading