Init Project
Some checks failed
Go CI Pipeline / build_and_test (push) Failing after 22m0s

This commit is contained in:
enkly
2026-10-30 18:06:55 +01:00
parent da8af794bd
commit 79ce8dc4c0
211 changed files with 44434 additions and 1 deletions

24
pkg/grpcerr/grpcerr.go Normal file
View File

@@ -0,0 +1,24 @@
// Package grpcerr has the handful of status-coded error constructors
// every service's interfaces/grpc package uses, so "not found" maps to
// codes.NotFound the same way in all eight of them instead of each
// service inventing its own convention.
package grpcerr
import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func NotFound(what string) error { return status.Errorf(codes.NotFound, "%s not found", what) }
func InvalidArgument(msg string) error { return status.Error(codes.InvalidArgument, msg) }
func FailedPrecondition(msg string) error { return status.Error(codes.FailedPrecondition, msg) }
func ResourceExhausted(msg string) error { return status.Error(codes.ResourceExhausted, msg) }
func Internal(err error) error { return status.Error(codes.Internal, err.Error()) }
func Unauthenticated(msg string) error { return status.Error(codes.Unauthenticated, msg) }
// Unavailable maps a dependency that is reachable-in-principle but not
// reachable right now (a vLLM deployment stuck Pending/restarting, a
// downstream service mid-rollout) onto codes.Unavailable instead of
// codes.Internal — gRPC clients and well-behaved gateways treat
// Unavailable as safe-to-retry, which an opaque Internal never is.
func Unavailable(err error) error { return status.Error(codes.Unavailable, err.Error()) }