utils

package
v0.0.0-...-0b48d5a Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: GPL-3.0 Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallOnce

func CallOnce(f func()) func()

CallOnce function decorator returns new function which can be called only once and is thread safe

func HardKiller

func HardKiller(kill Killer) func()

HardKiller invokes provided kill method and forces process to exit

func SoftKiller

func SoftKiller(kill Killer) func()

SoftKiller invokes killer and gives a chance for process to cleanup itself

Types

type ErrorCollection

type ErrorCollection []error

ErrorCollection knows how to combine multiple error strings

func (*ErrorCollection) Add

func (ec *ErrorCollection) Add(errors ...error)

Add puts given error to collection

func (*ErrorCollection) Error

func (ec *ErrorCollection) Error() error

Error converts collection to single error

func (*ErrorCollection) Errorf

func (ec *ErrorCollection) Errorf(format, errorDelimiter string) error

Errorf converts collection to single error by wanted format

func (*ErrorCollection) String

func (ec *ErrorCollection) String() string

String concatenates collection to single string

func (*ErrorCollection) Stringf

func (ec *ErrorCollection) Stringf(format, errorDelimiter string) string

Stringf returns a string representation of the underlying errors with the given format

type Killer

type Killer func() error

Killer kills some resource and performs cleanup

type SettableClock

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

SettableClock allows settings and getting time, which is convenient for testing

func (*SettableClock) AddTime

func (clock *SettableClock) AddTime(duration time.Duration)

AddTime adds given duration to current clock time

func (*SettableClock) GetTime

func (clock *SettableClock) GetTime() time.Time

GetTime returns set time

func (*SettableClock) SetTime

func (clock *SettableClock) SetTime(time time.Time)

SetTime sets time to be returned from GetTime

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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