util

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Annotate

func Annotate(err error, format string, args ...any) error

Annotate provides an additional context for the error.

func DoWork added in v0.1.6

func DoWork(work func(m *monitoring.Metrics), rate int, pauseMs int, m *monitoring.Metrics)

DoWork enables rate-limiting of client-provided work and accepts a random interval to pause between executions of the provided function, as well as a rate argument that defines the allowed number of operations per second.

func Fail

func Fail(err error, format string, args ...any)

A Fail prints the error message and then exits the program.

func GenString

func GenString(n int) string

GenString generates a random string with length n

func Random

func Random(min int, max int) int

Random generates a random number within a specified range.

func Sleep

func Sleep(n int)

Sleep pauses the execution of the program for the generated number of microsecond. Interval is generated randomly with the upper bound limit provided by you.

func ValidateStr

func ValidateStr(key string, keys []string)

ValidateStr checks if the string is allowed. Example:

ValidateStr("redis", []string{"redis", "memcached"}

func Warn

func Warn(err error, format string, args ...any)

A Warn notifies you that something has gone wrong with the execution of the program.

Types

This section is empty.

Jump to

Keyboard shortcuts

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