utils

package
v0.18.0-rc45-debug-qui... Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidIP = errors.New("invalid IP address or hostname given")

Functions

func CloseAndLog added in v0.20.2

func CloseAndLog(log logging.StandardLogger, name string, closer io.Closer)

CloseAndLog closes the closer and logs any error that occurs. The function is handy wrapping to group closing and logging in one call for defer statements.

func CtxWithSplitTimeout added in v0.20.2

func CtxWithSplitTimeout(
	ctx context.Context,
	splitFactor int,
	minTimeout time.Duration,
) (context.Context, context.CancelFunc)

CtxWithSplitTimeout will split timeout stored in context by splitFactor and return the result if it is greater than minTimeout. minTimeout == 0 will be ignored, splitFactor <= 0 will be ignored

func Exists

func Exists(path string) bool

Exists checks whether file or directory exists under the given 'path' on the system.

func ResetContextOnError added in v0.12.2

func ResetContextOnError(ctx context.Context) context.Context

ResetContextOnError returns a fresh context if the given context has an error.

func SanitizeAddr added in v0.5.0

func SanitizeAddr(addr string) (string, error)

SanitizeAddr trims leading protocol scheme and port from the given IP address or hostname if present.

func SetStatusAndEnd added in v0.6.3

func SetStatusAndEnd(span trace.Span, err error)

SetStatusAndEnd sets the status of the span depending on the contents of the passed error and ends it.

func SquareSize added in v0.7.0

func SquareSize(lenShares int) uint64

SquareSize returns the size of the square based on the given amount of shares.

func ValidateAddr added in v0.5.0

func ValidateAddr(addr string) (string, error)

ValidateAddr sanitizes the given address and verifies that it is a valid IP or hostname. The sanitized address is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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