util

package
v0.0.0-...-211e212 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CalculatePatch = patchMaker.Calculate
View Source
var OSFS osfs

OSFS represents the host operating system's FS.

View Source
var PreferredTempDirectory string
View Source
var SetLastAppliedAnnotation = annotator.SetLastAppliedAnnotation

Functions

func AnalyzeErrors

func AnalyzeErrors(msg string) error

AnalyzeErrors analyzes error messages to find oddities and potential bugs.

func CancelAny

func CancelAny(ctxs ...context.Context) context.Context

func Must

func Must(arg interface{}, err error) interface{}

func NotifyBackground

func NotifyBackground(ctx context.Context, timeout time.Duration, name string) *waitNotifier

func NotifyBlocking

func NotifyBlocking(ctx context.Context, timeout time.Duration, name string, f func())

func RunOnNotify

func RunOnNotify(ctx context.Context, c <-chan struct{}, funcs ...func())

RunPeriodic runs each function given in funcs (in parallel) every time the channel receives a value. It stops when either the channel is closed or the context is canceled.

func RunPeriodic

func RunPeriodic(
	ctx context.Context,
	duration time.Duration,
	factor float64,
	now bool,
	funcs ...func(),
)

RunPeriodic runs each function given in funcs (in parallel) every given duration until the context is done. A jitter factor can be provided, or set to a negative number to disable jitter. If now is true, the functions will be run once immediately before starting the timer.

func SetNotifyTimeoutHandler

func SetNotifyTimeoutHandler(handler func(NotifyTimeoutInfo))

func TopLevelTempDir

func TopLevelTempDir() (string, error)

Types

type HashServer

type HashServer struct {
	// contains filtered or unexported fields
}

HashServer uses the md5-simd library to allow highly concurrent hashing.

func NewHashServer

func NewHashServer() *HashServer

NewHashServer creates a new hash server.

func (*HashServer) Hash

func (hs *HashServer) Hash(obj Hashable) string

Hash hashes the given object using the hash server. This can and should be called simultaneously from multiple goroutines for maximum performance.

type Hashable

type Hashable interface {
	Hash(md5simd.Hasher)
}

Hashable represents an object which can be hashed using a md5simd.Hasher.

type NotifyTimeoutInfo

type NotifyTimeoutInfo struct {
	Name    string
	Message string
	Caller  string
}

type NullableError

type NullableError struct {
	// contains filtered or unexported fields
}

NullableError is a thread-safe wrapper around an error that ensures an error has been explicitly set, regardless of value, before being checked.

func (*NullableError) Err

func (ae *NullableError) Err() error

Err returns the error value stored in the NullableError. If the error has not been set using the Set method, this function will panic.

func (*NullableError) SetErr

func (ae *NullableError) SetErr(err error)

SetErr sets the error value and allows Err to be called.

type PauseController

type PauseController struct {
	// contains filtered or unexported fields
}

PauseController is an embeddable helper struct that allows an object to provide a means to "pause" and "resume" itself.

func NewPauseController

func NewPauseController(opts ...PauseControllerOption) *PauseController

NewPauseController creates and initializes a new pause controller.

func (*PauseController) CheckPaused

func (p *PauseController) CheckPaused()

CheckPaused blocks while the paused state is active. The implementation should call CheckPaused before and/or after a "pausable" section of code to enable the pause functionality. When paused, all calls to CheckPaused will block until Resume is called, after which CheckPaused will not block until Pause is called again.

func (*PauseController) Pause

func (p *PauseController) Pause()

Pause triggers an implementation-defined state where the object should cease its normal operations until unpaused.

func (*PauseController) Resume

func (p *PauseController) Resume()

Resume removes the paused state and unblocks any blocked calls to CheckPaused.

type PauseControllerOption

type PauseControllerOption func(*PauseControllerOptions)

func DefaultPaused

func DefaultPaused(paused bool) PauseControllerOption

DefaultPaused starts the controller paused. This should be used place of simply calling Pause right away to prevent race conditions.

type PauseControllerOptions

type PauseControllerOptions struct {
	// contains filtered or unexported fields
}

func (*PauseControllerOptions) Apply

type ReadDirStatFS

type ReadDirStatFS interface {
	fs.StatFS
	fs.ReadDirFS
}

type ZapfLogShim

type ZapfLogShim struct {
	ZapLogger *zap.SugaredLogger
}

ZapfLogShim implements the logr.Logger interface.

func (ZapfLogShim) Enabled

func (lg ZapfLogShim) Enabled(level int) bool

func (ZapfLogShim) Error

func (lg ZapfLogShim) Error(err error, msg string, keysAndValues ...interface{})

func (ZapfLogShim) Info

func (lg ZapfLogShim) Info(level int, msg string, keysAndValues ...interface{})

func (ZapfLogShim) Init

func (lg ZapfLogShim) Init(info logr.RuntimeInfo)

func (ZapfLogShim) V

func (lg ZapfLogShim) V(level int) logr.LogSink

func (ZapfLogShim) WithName

func (lg ZapfLogShim) WithName(name string) logr.LogSink

func (ZapfLogShim) WithValues

func (lg ZapfLogShim) WithValues(keysAndValues ...interface{}) logr.LogSink

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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