common

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: Apache-2.0 Imports: 10 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version current version - semantic format
	Version string
	// BuildTime time of the build
	BuildTime string
)
View Source
var Log = log.WithField("appname", "nsq-traefik-consumer")

Functions

func Flatten added in v1.0.3

func Flatten(thing map[string]interface{}) map[string]interface{}

Flatten takes a structure and turns into a flat map[string]string.

Within the "thing" parameter, only primitive values are allowed. Structs are not supported. Therefore, it can only be slices, maps, primitives, and any combination of those together.

See the tests for examples of what inputs are turned into.

func ServeStats added in v0.6.0

func ServeStats()

Types

type Config

type Config struct {
	Nsq        NsqConfig
	LogLevel   string
	LogAsJson  bool
	Kubernetes KubernetesConfig
	InfluxDB   InfluxDbConfig
	Rules      []RulesConfig
	Fields     []string
}

func NewConfig

func NewConfig() Config

type InfluxDbConfig

type InfluxDbConfig struct {
	Address         string
	Username        string
	Password        string
	Database        string
	Measurement     string
	RetentionPolicy string
	SendInterval    time.Duration
	BatchSize       int
}

type KubernetesConfig

type KubernetesConfig struct {
	AnnotationKey string
}

type NSQLogrusLogger

type NSQLogrusLogger struct{}

NSQLogrusLogger is an adaptor between the weird go-nsq Logger and our standard logrus logger.

func NewNSQLogrusLogger

func NewNSQLogrusLogger() (logger NSQLogrusLogger, level nsq.LogLevel)

NewNSQLogrusLogger returns a new NSQLogrusLogger and the current log level. This is a format to easily plug into nsq.SetLogger.

func NewNSQLogrusLoggerAtLevel

func NewNSQLogrusLoggerAtLevel(l log.Level) (logger NSQLogrusLogger, level nsq.LogLevel)

NewNSQLogrusLoggerAtLevel returns a new NSQLogrusLogger with the provided log level mapped to nsq.LogLevel for easily plugging into nsq.SetLogger.

func (NSQLogrusLogger) Output

func (n NSQLogrusLogger) Output(_ int, s string) error

Output implements stdlib log.Logger.Output using logrus Decodes the go-nsq log messages to figure out the log level

type NsqConfig

type NsqConfig struct {
	Addresses    []string
	Topic        string
	Channel      string
	MaxInFlight  int
	ClientConfig *nsq.Config
}

type RulesConfig

type RulesConfig struct {
	Id             string
	UrlRegexp      string
	FrontendRegexp string
	MethodRegexp   string
	Sampling       float64
}

type VersionInfo

type VersionInfo struct {
	Version   string `json:"version"`
	BuildTime string `json:"build_time"`
}

VersionInfo holds the information about current app version

func GetCurrentVersion

func GetCurrentVersion() VersionInfo

GetCurrentVersion returns information about current version of the app

func (VersionInfo) String

func (v VersionInfo) String() string

Jump to

Keyboard shortcuts

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