Documentation ¶
Overview ¶
Package glogger defines glog-based logging for grpc.
Index ¶
- Variables
- func CapitalizeString(str string) string
- func CompareErr(errA, errB error) int
- func GetAuthToken(ctx context.Context, scheme string) (string, error)
- func GetRPCErrDesc(err error) string
- func GetResourceSet(memory, cpuShare int) map[string]map[string]int
- func GetShortID(id string) string
- func HasEnv(envs ...string) []string
- func IsUniqueConstraintError(err error, column string) bool
- func IsValidACLTarget(target string) error
- func IsValidCocoonID(name string) bool
- func IsValidResName(name string) bool
- func JSONCoerceErr(objName string, err error) error
- func MBToByte(mb int64) int64
- func MergeMapSlice(s []map[string]interface{}) map[string]interface{}
- func NewLock(key string) (types.Lock, error)
- func NewLockWithTTL(key string, ttl time.Duration) (types.Lock, error)
- func OnTerminate(f func(s os.Signal))
- func ReRunOnError(f func() error, times int, delay time.Duration) error
- func RemoveASCIIColors(s []byte) []byte
- func ResolveFirewall(rules types.Firewall) (types.Firewall, error)
- func ReturnFirstIfDiffACLMap(a, b types.ACLMap) types.ACLMap
- func ReturnFirstIfDiffEnv(a, b types.Env) types.Env
- func ReturnFirstIfDiffInt(a, b int) int
- func ReturnFirstIfDiffString(a, b string, secondIfEmpty bool) string
- func Round(val float64) int
- func SimpleGRPCError(serviceName string, err error) error
- func ToRPCError(code int, err error) error
- type GLogger
- func (g *GLogger) Disable(v bool, includeFatal bool)
- func (g *GLogger) Fatal(args ...interface{})
- func (g *GLogger) Fatalf(format string, args ...interface{})
- func (g *GLogger) Fatalln(args ...interface{})
- func (g *GLogger) Print(args ...interface{})
- func (g *GLogger) Printf(format string, args ...interface{})
- func (g *GLogger) Println(args ...interface{})
Constants ¶
This section is empty.
Variables ¶
var SupportedResourceSets = map[string]map[string]int{
"s1": {
"cpuShare": 100,
"memory": 256,
"disk": 4000,
},
"s2": {
"cpuShare": 100,
"memory": 512,
"disk": 4000,
},
"m1": {
"cpuShare": 100,
"memory": 1024,
"disk": 4000,
},
"m2": {
"cpuShare": 200,
"memory": 2048,
"disk": 4000,
},
}
SupportedResourceSets defines the support sets of resources that can be allocated to a task
Functions ¶
func CapitalizeString ¶
CapitalizeString capitalizes the first character of all sentences in a given string.
func CompareErr ¶
CompareErr compares two error string values. Returns 0 if equal. Removes GRPC prefixes if available.
func GetAuthToken ¶
GetAuthToken returns authorization code of a specific bearer from a context
func GetRPCErrDesc ¶
GetRPCErrDesc takes a grpc generated error and returns the description. If error is not grpc generated, it returns err.Error().
func GetResourceSet ¶
GetResourceSet returns the full resource where the resource attributes match the one passed
func HasEnv ¶
HasEnv checks whether a slice of environment variable have been set. It returns the variables that haven't been set
func IsUniqueConstraintError ¶
IsUniqueConstraintError checks whether an error is a postgres contraint error affecting a column.
func IsValidACLTarget ¶
IsValidACLTarget checks whether an ACL target format is valid
func IsValidCocoonID ¶
IsValidCocoonID checks whether a name is a accepted cocoon name
func IsValidResName ¶
IsValidResName checks whether a name is a accepted resource name format.
func JSONCoerceErr ¶
JSONCoerceErr returns an error about an error converting json data to an object
func MergeMapSlice ¶
MergeMapSlice merges a slice of maps into a single map with the each successive maps overwriting previously available keys
func NewLockWithTTL ¶
NewLockWithTTL creates a lock with a custom ttl. If `DEV_MEM_LOCK` is set, a memory lock will be returned
func OnTerminate ¶
OnTerminate calls a function when a terminate or interrupt signal is received.
func ReRunOnError ¶
ReRunOnError runs a function multiple times till it returns a non-error (nil) value. It accepts a limit on how many times to attempt a re-run and a delay duration. If delay is nil, there is no delay. It returns the last error of the last re-run attempt if the function did not succeed.
func RemoveASCIIColors ¶
RemoveASCIIColors takes a byte slice and remove ASCII colors
func ResolveFirewall ¶
ResolveFirewall performs a reverse lookup of non-IP destination of every rule. For each resolved rule, a new cloned rule is added with the looked up IP used as the destination.
func ReturnFirstIfDiffACLMap ¶
ReturnFirstIfDiffACLMap returns the first param (a) if it is different from the (b), otherwise b is returned
func ReturnFirstIfDiffEnv ¶
ReturnFirstIfDiffEnv returns the first param (a) if it is different from the (b), otherwise b is returned
func ReturnFirstIfDiffInt ¶
ReturnFirstIfDiffInt returns the first param (a) if it is different from the (b) and not zero, otherwise b is returned
func ReturnFirstIfDiffString ¶
ReturnFirstIfDiffString returns the first param (a) if it is different from the (b), otherwise b is returned
func SimpleGRPCError ¶
SimpleGRPCError returns simplified, user-friendly grpc errors
func ToRPCError ¶
ToRPCError creates an RPC error message
Types ¶
type GLogger ¶
type GLogger struct {
// contains filtered or unexported fields
}
GLogger defines glog-based logging for grpc. This is a modification of glogger (https://github.com/grpc/grpc-go/blob/master/grpclog/glogger/glogger.go) that includes a new Disable function to disable logging.