util

package
Version: v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckErrors

func CheckErrors(errs ...error) error

CheckErrors is used to check multi errors

func Dump

func Dump(message interface{}) error

Dump is used to dump object into stdout

func DumpYaml

func DumpYaml(cfg interface{})

DumpYaml is used to dump yaml into stdout

func GRPCLoggingMiddleware

func GRPCLoggingMiddleware(logger logger.Logger) grpc.UnaryServerInterceptor

GRPCLoggingMiddleware is grpc logging middleware

func GetHTTPCodeFromError

func GetHTTPCodeFromError(err error) int

GetHTTPCodeFromError is used to get http code from error

func GetPagination

func GetPagination(options *v1alpha1.ListOptions) *v1alpha1.ListOptions

GetPagination is used to make ListOptions safety

func IgnoredFlag

func IgnoredFlag(f *pflag.FlagSet, name, message string)

IgnoredFlag ignores set value, without any warning

func LoadConfig

func LoadConfig(filename string, pointer interface{}) error

LoadConfig read YAML-formatted config from filename into cfg.

func PaginateSlice

func PaginateSlice(options *v1alpha1.ListOptions, pointer interface{}) error

PaginateSlice is used to paginate slice

func ParseConfigFileParameter

func ParseConfigFileParameter(args []string) (configFile string)

Parse -config.file and -config.expand-env option via separate flag set, to avoid polluting default one and calling flag.Parse on it twice.

func RegisterExitHandlers

func RegisterExitHandlers(logger logger.Logger, cancelFunc func()) (stop chan struct{})

RegisterExitHandlers is used to register exit handlers

func SplitYAML

func SplitYAML(data []byte) ([][]byte, error)

SplitYAML is used to split yaml

func StartMetricsServer

func StartMetricsServer(ctx context.Context, cancelFunc context.CancelFunc, logger logger.Logger, address string, registerer prometheus.Registerer) error

StartMetricsServer is used to start metric server

func StartServiceAsync

func StartServiceAsync(ctx context.Context, cancelFunc context.CancelFunc, logger logger.Logger, serveFn func() error, stopFn func() error)

StartServiceAsync is used to start service async

func ValidateConfigs

func ValidateConfigs(configs ...ValidatableConfig) error

ValidateConfigs is used to validate validatable configs

Types

type PluggableConfig

type PluggableConfig interface {
	// IsEnabled is used to return whether the current component is enabled
	// This attribute is required in pluggable components
	IsEnabled() bool
}

PluggableConfig defines the pluggable Config

type RegistrableConfig

type RegistrableConfig interface {
	// RegisterFlagsWithPrefix is used to registerer flag with prefix
	RegisterFlagsWithPrefix(prefix string, f *pflag.FlagSet)
}

RegistrableConfig defines the registrable config

type ValidatableConfig

type ValidatableConfig interface {
	// Validate is used to validate config and returns error on failure
	Validate() error
}

ValidatableConfig defines the validatable Config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to