utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	LAVA_LOG_TRACE = iota
	LAVA_LOG_DEBUG
	LAVA_LOG_INFO
	LAVA_LOG_WARN
	LAVA_LOG_ERROR
	LAVA_LOG_FATAL
	LAVA_LOG_PANIC
	LAVA_LOG_PRODUCTION
	NoColor = true
)
View Source
const (
	KEY_REQUEST_ID     = "request_id"
	KEY_TASK_ID        = "task_id"
	KEY_TRANSACTION_ID = "tx_id"
)
View Source
const (
	EventPrefix = "lava_"
)
View Source
const MONTHS_IN_YEAR = 12
View Source
const TIMEOUT = 10

Variables

View Source
var (
	JsonFormat = false
	// if set to production, this will replace some errors to warning that can be caused by misuse instead of bugs
	ExtendedLogLevel = "development"
)
View Source
var (
	TimeoutMutex           = "false"
	TimeoutMutexBoolean, _ = strconv.ParseBool(TimeoutMutex)
)
View Source
var DebugPaymentE2E = "" // using "debug_payment_e2e" build option, this string will be "debug_payment_e2e"

Functions

func AppendRequestId

func AppendRequestId(ctx context.Context, reqId string) context.Context

func AppendTaskId

func AppendTaskId(ctx context.Context, taskId string) context.Context

func AppendTxId

func AppendTxId(ctx context.Context, txId string) context.Context

func AppendUniqueIdentifier

func AppendUniqueIdentifier(ctx context.Context, guid uint64) context.Context

func Btof

func Btof(b bool) float64

func Deserialize

func Deserialize(raw []byte, data any)

func ExtractWantedHeadersFromCachedMap

func ExtractWantedHeadersFromCachedMap(headers map[string][]string, ctx context.Context) context.Context

ExtractWantedHeadersFromCachedMap extracts specific headers from a pre-cached headers map and adds them to the Go context. This avoids repeated header lookups when headers are already cached via GetReqHeaders().

func FormatLongString

func FormatLongString(msg string, maxCharacters int) string

func FormatStringerList

func FormatStringerList[T fmt.Stringer](description string, listToPrint []T, separator string) string

func GenerateUniqueIdentifier

func GenerateUniqueIdentifier() uint64

func GetRequestId

func GetRequestId(ctx context.Context) (reqId string, found bool)

func GetTaskId

func GetTaskId(ctx context.Context) (taskId string, found bool)

func GetTxId

func GetTxId(ctx context.Context) (txId string, found bool)

func GetUniqueIdentifier

func GetUniqueIdentifier(ctx context.Context) (guid uint64, found bool)

func IsDebugEnabled

func IsDebugEnabled() bool

IsDebugEnabled reports whether debug-level logging is currently active. Use this to guard expensive pre-call computations that are only needed when a debug log will actually be emitted.

func IsMiddleOfMonthPassed

func IsMiddleOfMonthPassed(date time.Time) bool

func IsTraceLogLevelEnabled

func IsTraceLogLevelEnabled() bool

func LavaFormatDebug

func LavaFormatDebug(description string, attributes ...Attribute) error

func LavaFormatError

func LavaFormatError(description string, err error, attributes ...Attribute) error

func LavaFormatFatal

func LavaFormatFatal(description string, err error, attributes ...Attribute)

func LavaFormatInfo

func LavaFormatInfo(description string, attributes ...Attribute) error

func LavaFormatLog

func LavaFormatLog(description string, err error, attributes []Attribute, severity uint) error

func LavaFormatPanic

func LavaFormatPanic(description string, err error, attributes ...Attribute)

func LavaFormatProduction

func LavaFormatProduction(description string, err error, attributes ...Attribute) error

see documentation in LavaFormatLog function

func LavaFormatTrace

func LavaFormatTrace(description string, attributes ...Attribute) error

func LavaFormatWarning

func LavaFormatWarning(description string, err error, attributes ...Attribute) error

func Max

func Max[T cmp.Ordered](x, y T) T

func Min

func Min[T cmp.Ordered](x, y T) T

func NextMonth

func NextMonth(date time.Time) time.Time

NextMonth returns the date of the same day next month (assumes UTC), adjusting for end-of-months differences if needed.

func RollingLoggerSetup

func RollingLoggerSetup(rollingLogLevel string, filePath string, maxSize string, maxBackups string, maxAge string, stdFormat string) func()

func SafeUint64ToInt64Convert

func SafeUint64ToInt64Convert(val uint64) int64

func Serialize

func Serialize(data any) []byte

func SetGlobalLoggingLevel

func SetGlobalLoggingLevel(logLevel string)

func SetLogLevelFieldName

func SetLogLevelFieldName(fieldName string)

func StrValue

func StrValue(val interface{}) string

func StrValueForLog

func StrValueForLog(val interface{}, key string, idx int, attributes []Attribute) string

func ToHexString

func ToHexString(hash string) string

func WithRequestId

func WithRequestId(ctx context.Context, reqId string) context.Context

func WithTaskId

func WithTaskId(ctx context.Context, taskId string) context.Context

func WithTxId

func WithTxId(ctx context.Context, txId string) context.Context

func WithUniqueIdentifier

func WithUniqueIdentifier(ctx context.Context, guid uint64) context.Context

Types

type Attribute

type Attribute struct {
	Key   string
	Value interface{}
}

func LogAttr

func LogAttr(key string, value interface{}) Attribute

func StringMapToAttributes

func StringMapToAttributes(details map[string]string) []Attribute

type ChanneledWaitGroup

type ChanneledWaitGroup struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

func NewChanneledWaitGroup

func NewChanneledWaitGroup() *ChanneledWaitGroup

func (*ChanneledWaitGroup) Wait

func (wg *ChanneledWaitGroup) Wait() <-chan struct{}

type LavaMutex

type LavaMutex struct {
	SecondsLeft int
	// contains filtered or unexported fields
}

func (*LavaMutex) Lock

func (dm *LavaMutex) Lock()

func (*LavaMutex) TryLock

func (dm *LavaMutex) TryLock() (isLocked bool)

func (*LavaMutex) Unlock

func (dm *LavaMutex) Unlock()

type Lockable

type Lockable interface {
	Lock()
	TryLock() bool
	Unlock()
}

type LoggerWrapper

type LoggerWrapper struct {
	LoggerName string
}

this logger is used for any third party loggers that require the logging functionality to be a bit different than the lava logger functionality

func (LoggerWrapper) Debugf

func (lw LoggerWrapper) Debugf(msg string, extraInfo ...interface{})

func (LoggerWrapper) Errorf

func (lw LoggerWrapper) Errorf(msg string, extraInfo ...interface{})

func (LoggerWrapper) Infof

func (lw LoggerWrapper) Infof(msg string, extraInfo ...interface{})

func (LoggerWrapper) Warningf

func (lw LoggerWrapper) Warningf(msg string, extraInfo ...interface{})

Directories

Path Synopsis
Package specfetcher provides functionality to fetch Lava specs from remote Git repositories.
Package specfetcher provides functionality to fetch Lava specs from remote Git repositories.

Jump to

Keyboard shortcuts

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