common

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckErr

func CheckErr(err error)

CheckErr ends in a fatal log if err is not nil.

func CheckErrf

func CheckErrf(format string, err error)

CheckErrf ends in a fatal log if err is not nil.

func ConfigureCLI

func ConfigureCLI(v *viper.Viper, envPrefix string, flags []Flag, flagSet *pflag.FlagSet)

ConfigureCLI configures a Viper environment with flags and envs.

func ConfigureLogging

func ConfigureLogging(v *viper.Viper, logLevels []string) error

ConfigureLogging configures the default logger with the right setup depending flag/envs. If logLevels is not nil, only logLevels values will be configured to Info/Debug depending on viper flags. if logLevels is nil, all sub-logs will be configured.

func ExpandEnvVars

func ExpandEnvVars(v *viper.Viper, settings map[string]interface{})

ExpandEnvVars expands env vars present in the config.

func GrpcLoggerInterceptor

func GrpcLoggerInterceptor(log *logger.ZapEventLogger) grpc.UnaryServerInterceptor

GrpcLoggerInterceptor logs any error produced by processing requests, and catches/recovers from panics.

func HandleInterrupt

func HandleInterrupt(cleanup func())

HandleInterrupt attempts to cleanup while allowing the user to force stop the process.

func ParseStringSlice

func ParseStringSlice(v *viper.Viper, key string) []string

ParseStringSlice returns a single slice of values that may have been set by either repeating a flag or using comma separation in a single flag. This is used to enable repeated flags as well as env vars that can't be repeated. In either case, Viper understands how to write the config entry as a list.

func SetupInstrumentation

func SetupInstrumentation(prometheusAddr string) error

SetupInstrumentation starts a metrics endpoint.

Types

type Flag

type Flag struct {
	Name        string
	DefValue    interface{}
	Description string
}

Flag describes a configuration flag.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL