util

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: AGPL-3.0 Imports: 14 Imported by: 65

Documentation

Index

Constants

View Source
const (
	SIGHUP  = 0x1
	SIGINT  = 0x2
	SIGQUIT = 0x3
	SIGTERM = 0xF
)
View Source
const (
	TimeFormat = "2006-01-02T15:04:05.000Z"
)
View Source
const (
	// This is the canonical timestamp format used by Faktory.
	// Always UTC, lexigraphically sortable.  This is the best
	// timestamp format, accept no others.
	TimestampFormat = time.RFC3339Nano
)

Variables

View Source
var (
	LogInfo  = false
	LogDebug = false
)
View Source
var (
	// Set FAKTORY2_PREVIEW=true to enable breaking changes coming in Faktory 2.0.
	Faktory2Preview bool = Must(strconv.ParseBool(cmp.Or(os.Getenv("FAKTORY2_PREVIEW"), "false")))
)

Functions

func Backtrace

func Backtrace(size int) []string

Backtrace gathers a backtrace for the caller. Return a slice of up to N stack frames.

func Darwin

func Darwin() bool

func Debug

func Debug(arg string)

Verbosity level helps track down production issues:

-l debug

func Debugf

func Debugf(msg string, args ...interface{})

Verbosity level helps track down production issues:

-l debug

func DumpProcessTrace added in v1.5.0

func DumpProcessTrace()

func EnsureChildShutdown added in v1.5.0

func EnsureChildShutdown(cmd *exec.Cmd, sig int)

func Error

func Error(msg string, err error)

func FileExists

func FileExists(path string) (bool, error)

FileExists checks if given file exists

func Info

func Info(arg string)

Typical logging output, the default level

func Infof

func Infof(msg string, args ...interface{})

Typical logging output, the default level

func InitLogger

func InitLogger(level string)

func JsonUnmarshal added in v1.9.0

func JsonUnmarshal(data []byte, target any) error

func MemoryUsageMB added in v1.5.1

func MemoryUsageMB() uint64

func Must added in v1.9.0

func Must[T any](obj T, err error) T

func Nows

func Nows() string

func ParseTime

func ParseTime(str string) (time.Time, error)

func RandomInt63 added in v1.5.2

func RandomInt63() (int64, error)

func RandomJid

func RandomJid() string

func Retryable added in v1.5.0

func Retryable(ctx context.Context, name string, count int, fn func() error) error

func Thens

func Thens(tim time.Time) string

func Warn

func Warn(arg string)

Uh oh, not good but not worthy of process death

func Warnf

func Warnf(msg string, args ...interface{})

Types

type Level added in v1.5.0

type Level int
const (
	InvalidLevel Level = iota - 1
	DebugLevel
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel
)

Jump to

Keyboard shortcuts

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