util

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetadataClampMin          = "clampMin"
	MetadataClampMax          = "clampMax"
	MetadataMetricQuery       = "metricQuery"
	MetadataTargetValue       = "targetValue"
	MetadataOperationOverTime = "operationOverTime"

	MetadataOperationOverTimeDefaultValue = types.OpLastOne
)
View Source
const DebugLvl = -1

Variables

This section is empty.

Functions

func CheckTimeOp

func CheckTimeOp(op types.OperationOverTime) error

func ClampValue

func ClampValue(lggr logr.Logger, value float64, metadata map[string]string) float64

func ContextWithLogger

func ContextWithLogger(ctx context.Context, logger logr.Logger) context.Context

func Filter

func Filter[I any](input []I, f func(I) bool) []I

func Filter2

func Filter2[I any](input []I, f func(I) bool) []I

func FlatMap

func FlatMap[I, R any](input []I, f func(I) []R) []R

func GetOperationOvertTime

func GetOperationOvertTime(lggr logr.Logger, metadata map[string]string) types.OperationOverTime

func GetTargetValue

func GetTargetValue(metadata map[string]string) (int64, error)

func IsDebug

func IsDebug(lvl zapcore.LevelEnabler) bool

func IsIgnoredErr

func IsIgnoredErr(err error) bool

func Map

func Map[I, R any](input []I, f func(I) R) []R

func NamespacedNameFromScaledObjectRef

func NamespacedNameFromScaledObjectRef(sor *externalscaler.ScaledObjectRef) *types.NamespacedName

func PrintBanner

func PrintBanner(noColor bool)

func ResolveOsEnvBool

func ResolveOsEnvBool(envName string, defaultValue bool) (bool, error)

func ResolveOsEnvDuration

func ResolveOsEnvDuration(envName string) (*time.Duration, error)

func ResolveOsEnvInt

func ResolveOsEnvInt(envName string, defaultValue int) (int, error)

func SetupLog

func SetupLog(noColor bool) zapcore.LevelEnabler

SetupLog tweak the default log to use custom time format and use colors if supported

func SplitAfter

func SplitAfter(s string, re *regexp.Regexp) (r []string)

SplitAfter works as the same way as strings.SplitAfter() but the separator is regexp

Types

type Config

type Config struct {
	OTLPReceiverPort            int  `envconfig:"OTLP_RECEIVER_PORT" default:"4317"`
	KedaExternalScalerPort      int  `envconfig:"KEDA_EXTERNAL_SCALER_PORT" default:"4318"`
	RestApiPort                 int  `envconfig:"REST_API_PORT" default:"9090"`
	InternalMetricsPort         int  `envconfig:"INTERNAL_METRICS_PORT" default:"8080"`
	MetricStoreRetentionSeconds int  `envconfig:"METRIC_STORE_RETENTION_SECONDS" default:"120"`
	NoColor                     bool `envconfig:"NO_COLOR" default:"false"`
	NoBanner                    bool `envconfig:"NO_BANNER" default:"false"`
}

func MustParseConfig

func MustParseConfig() *Config

Jump to

Keyboard shortcuts

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