Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToString(b []byte) string
- func CheckMapEqual(pre, cur map[string]string) bool
- func Clamp(value, min, max float64) float64
- func CmpBool(a, b bool) int
- func CmpError(err1, err2 error) int
- func CmpFloat64(a, b float64) int
- func CmpInt32(a, b int32) int
- func CmpString(a, b string) int
- func ConvertBytesToPages(bytes int) int
- func CovertInt64ToInt(numInt64 int64) (int, error)
- func CovertUInt64ToInt(numUInt64 uint64) (int, error)
- func DedupStringSlice(input []string) []string
- func DeepCopyFload64Map(origin map[string]float64) map[string]float64
- func DeepCopyIntMap(origin map[string]int) map[string]int
- func DeepCopyIntToIntMap(origin map[int]int) map[int]int
- func DeepCopyMap(origin map[string]string) map[string]string
- func EnsureDirectory(dir string) error
- func ErrorS(err error, message string, params ...interface{})
- func ErrorSPath(pkg LoggingPKG, err error, message string, params ...interface{})
- func Errorf(message string, params ...interface{})
- func ErrorfPath(pkg LoggingPKG, message string, params ...interface{})
- func Fatalf(message string, params ...interface{})
- func FatalfPath(pkg LoggingPKG, message string, params ...interface{})
- func FilterStringToStringMapByKeys(keptKeys []string, originalMap map[string]string) map[string]string
- func FormatMemoryQuantity(q float64) string
- func GenerateHash(data []byte, length int) string
- func GetInt64PointerFromUint64Pointer(v *uint64) (*int64, error)
- func GetOneExistPath(paths []string) string
- func GetOneExistPathUntilExist(paths []string, checkInterval, timeoutDuration time.Duration) (string, error)
- func GetPageSize() int
- func GetRegisterReadinessCheckResult() map[HealthzCheckName]HealthzCheckResult
- func GetSortedMapKeys(m map[string]int) []string
- func GetStringValueFromMap(m map[string]string, key string) string
- func GetValueWithDefault(m map[string]string, key, defaultV string) string
- func InfoS(message string, params ...interface{})
- func InfoSPath(pkg LoggingPKG, message string, params ...interface{})
- func Infof(message string, params ...interface{})
- func InfofPath(pkg LoggingPKG, message string, params ...interface{})
- func InfofV(level int, message string, params ...interface{})
- func InfofVPath(pkg LoggingPKG, level int, message string, params ...interface{})
- func IntSliceToStringSlice(a []int) []string
- func IsErrKeyNotExist(err error) bool
- func IsErrNotFound(err error) bool
- func IsNameEnabled(name string, disabledByDefault sets.String, enableNames []string) bool
- func IsPathExists(path string) bool
- func IsUnimplementedError(err error) bool
- func IsUnmarshalTypeError(err error) bool
- func JsonPathEmpty(str []byte) bool
- func LoadJsonConfig(configAbsPath string, configObject interface{}) error
- func Max(a, b int) int
- func MaxFloat64(a, b float64) float64
- func MaxInt64(a, b int64) int64
- func MaxTimePtr(a, b *time.Time) *time.Time
- func MaxUInt64(a, b uint64) uint64
- func MergeMap(src, override map[string]string) map[string]string
- func MergeMapInt(src, override map[string]int) map[string]int
- func Min(a, b int) int
- func MinFloat64(a, b float64) float64
- func MinInt64(a, b int64) int64
- func MinUInt32(a, b uint32) uint32
- func MinUInt64(a, b uint64) uint64
- func ParseMapWithPrefix(prefix, selector string) (map[string]string, error)
- func ParseStringToUint64Pointer(s string) (*uint64, error)
- func ParseUint64PointerToString(v *uint64) string
- func ReadFileIntoInt(filepath string) (int, error)
- func ReadFileIntoLines(filepath string) ([]string, error)
- func RegisterFileEventWatcher(stop <-chan struct{}, fileWatcherInfo FileWatcherInfo) (<-chan struct{}, error)
- func RegisterHeartbeatCheck(name string, timeout time.Duration, initState HealthzCheckState, ...)
- func RegisterReportCheck(name string, autoRecoverPeriod time.Duration)
- func RegisterTemporaryHeartbeatCheck(name string, timeout time.Duration, initState HealthzCheckState, ...)
- func RegisterTemporaryReportCheck(name string, autoRecoverPeriod time.Duration)
- func ReleaseUniqueLock(lock *Flock)
- func SetDefaultLoggingPackage(l LoggingPKG)
- func SliceContains(list interface{}, elem interface{}) bool
- func StructToString(val interface{}) string
- func SumUpMapValues(m map[string]int) int
- func SumUpMultipleMapValues(m map[string]map[string]int) int
- func ToString(in interface{}) string
- func UInt64PointerToFloat64(p *uint64) float64
- func UIntPointerToFloat64(p *uint) float64
- func UnregisterTemporaryHeartbeatCheck(name string)
- func UnregisterTemporaryReportCheck(name string)
- func UpdateHealthzState(name string, state HealthzCheckState, message string) error
- func UpdateHealthzStateByError(name string, err error) error
- func Warningf(message string, params ...interface{})
- func WarningfPath(pkg LoggingPKG, message string, params ...interface{})
- type CappedSmoothWindow
- type CmpFunc
- type CommonSuffixTranslator
- type FileWatcherInfo
- type Flock
- type HealthzCheckFunc
- type HealthzCheckMode
- type HealthzCheckName
- type HealthzCheckResult
- type HealthzCheckState
- type Logger
- func (l Logger) ErrorS(err error, message string, params ...interface{})
- func (l Logger) Errorf(message string, params ...interface{})
- func (l Logger) Fatalf(message string, params ...interface{})
- func (l Logger) InfoS(message string, params ...interface{})
- func (l Logger) Infof(message string, params ...interface{})
- func (l Logger) InfofV(level int, message string, params ...interface{})
- func (l Logger) Warningf(message string, params ...interface{})
- type LoggingPKG
- type MultiSorter
- type Pair
- type ResourceList
- type SmoothWindow
- type SmoothWindowOpts
- type SourceList
- type TTLSmoothWindow
Constants ¶
const ( FlockCoolingInterval = 6 * time.Second FlockTryLockMaxTimes = 10 )
const ( HealthzCheckStateReady HealthzCheckState = "Ready" HealthzCheckStateNotReady HealthzCheckState = "NotReady" HealthzCheckStateUnknown HealthzCheckState = "Unknown" HealthzCheckStateFailed HealthzCheckState = "Failed" InitMessage = "Init" // HealthzCheckModeHeartBeat in this mode, caller should update the check status regularly like a heartbeat, once // the heartbeat stops for more than TimeoutPeriod or the state is not HealthzCheckStateReady for more than GracePeriod, // this rule will be considered as unhealthy. HealthzCheckModeHeartBeat HealthzCheckMode = "heartbeat" // HealthzCheckModeReport in this mode, caller only reports the failed state when the function does not work well. // when the LatestUnhealthyTime is not earlier than the GracePeriod ago, we consider this rule as unhealthy. // if caller doesn't report new failed state for more than GracePeriod, we consider the exception recovered. HealthzCheckModeReport HealthzCheckMode = "report" )
const ( SmoothWindowAggFuncAvg = "average" SmoothWindowAggFuncPerc = "percentile" )
const (
DefaultPageSize = 4096
)
Variables ¶
var ( ErrNotFound = fmt.Errorf("not found") ErrKeyNotExist = errors.New("key does not exist") )
common errors
var NativeEndian binary.ByteOrder
NativeEndian is the native endian
Functions ¶
func BytesToString ¶ added in v0.4.1
func CheckMapEqual ¶
func Clamp ¶ added in v0.3.0
Clamp returns value itself if min < value < max; min if value < min; max if value > max
func CmpFloat64 ¶
CmpFloat64 compares float64s, placing greater before smaller
func ConvertBytesToPages ¶ added in v0.5.9
ConvertBytesToPages return pages number from bytes
func CovertInt64ToInt ¶ added in v0.2.0
func CovertUInt64ToInt ¶ added in v0.2.0
func DedupStringSlice ¶ added in v0.5.1
DedupStringSlice return deduplicated string slice from original
func DeepCopyFload64Map ¶ added in v0.4.0
func EnsureDirectory ¶
func ErrorSPath ¶ added in v0.3.0
func ErrorSPath(pkg LoggingPKG, err error, message string, params ...interface{})
func ErrorfPath ¶ added in v0.3.0
func ErrorfPath(pkg LoggingPKG, message string, params ...interface{})
func FatalfPath ¶ added in v0.3.0
func FatalfPath(pkg LoggingPKG, message string, params ...interface{})
func FilterStringToStringMapByKeys ¶ added in v0.5.8
func FilterStringToStringMapByKeys(keptKeys []string, originalMap map[string]string) map[string]string
FilterPodAnnotationKeptKeys filter keys kept in qrm state
func FormatMemoryQuantity ¶ added in v0.3.0
FormatMemoryQuantity aligned to Gi Mi Ki
func GenerateHash ¶
func GetOneExistPath ¶
GetOneExistPath is to get one of exist paths
func GetOneExistPathUntilExist ¶ added in v0.5.9
func GetOneExistPathUntilExist(paths []string, checkInterval, timeoutDuration time.Duration, ) (string, error)
GetOneExistPathUntilExist returns a path until one provided path exists
func GetPageSize ¶ added in v0.5.9
func GetPageSize() int
func GetRegisterReadinessCheckResult ¶ added in v0.4.1
func GetRegisterReadinessCheckResult() map[HealthzCheckName]HealthzCheckResult
func GetSortedMapKeys ¶ added in v0.2.0
GetSortedMapKeys returns a slice containing sorted keys for the given map
func GetValueWithDefault ¶
GetValueWithDefault gets value from the given map, and returns default if key not exist
func InfoSPath ¶ added in v0.3.0
func InfoSPath(pkg LoggingPKG, message string, params ...interface{})
func InfofPath ¶ added in v0.3.0
func InfofPath(pkg LoggingPKG, message string, params ...interface{})
func InfofVPath ¶ added in v0.3.0
func InfofVPath(pkg LoggingPKG, level int, message string, params ...interface{})
func IntSliceToStringSlice ¶
func IsErrKeyNotExist ¶ added in v0.4.0
func IsErrNotFound ¶ added in v0.3.0
func IsNameEnabled ¶
IsNameEnabled check if a specified name enabled or not.
func IsPathExists ¶
IsPathExists is to check this path whether exists
func IsUnimplementedError ¶ added in v0.4.0
func IsUnmarshalTypeError ¶ added in v0.2.0
IsUnmarshalTypeError check whether is json unmarshal type error
func JsonPathEmpty ¶
JsonPathEmpty is used to check whether the given str is empty for json-patch
func LoadJsonConfig ¶ added in v0.4.0
func MaxFloat64 ¶ added in v0.3.0
func MergeMapInt ¶ added in v0.2.0
MergeMapInt merges the contents from override into the src
func MinFloat64 ¶ added in v0.4.0
func ParseMapWithPrefix ¶
ParseMapWithPrefix converts selector string to label map and validates keys and values
func ReadFileIntoInt ¶ added in v0.2.0
ReadFileIntoInt read contents from the given file, and parse them into integer
func ReadFileIntoLines ¶ added in v0.2.0
ReadFileIntoLines read contents from the given file, and parse them into string slice; each string indicates a line in the file
func RegisterFileEventWatcher ¶
func RegisterFileEventWatcher(stop <-chan struct{}, fileWatcherInfo FileWatcherInfo) (<-chan struct{}, error)
RegisterFileEventWatcher inotify the given file and report the changed information to the caller through returned channel
func RegisterHeartbeatCheck ¶ added in v0.4.1
func RegisterReportCheck ¶ added in v0.4.1
func RegisterTemporaryHeartbeatCheck ¶ added in v0.5.7
func RegisterTemporaryReportCheck ¶ added in v0.5.7
func ReleaseUniqueLock ¶
func ReleaseUniqueLock(lock *Flock)
ReleaseUniqueLock release the given file lock
func SetDefaultLoggingPackage ¶ added in v0.3.0
func SetDefaultLoggingPackage(l LoggingPKG)
SetDefaultLoggingPackage should only be called by flags, and should not be alerted dynamically.
func SliceContains ¶ added in v0.4.1
func SliceContains(list interface{}, elem interface{}) bool
SliceContains returns true if an element is present in a slice.
func StructToString ¶ added in v0.4.1
func StructToString(val interface{}) string
func SumUpMapValues ¶ added in v0.2.0
SumUpMapValues accumulates total values for the given map
func SumUpMultipleMapValues ¶ added in v0.2.0
SumUpMultipleMapValues accumulates total values for the given multi-level map
func ToString ¶
func ToString(in interface{}) string
ToString transform to string for better display etc. in log
func UInt64PointerToFloat64 ¶
func UIntPointerToFloat64 ¶
func UnregisterTemporaryHeartbeatCheck ¶ added in v0.5.7
func UnregisterTemporaryHeartbeatCheck(name string)
func UnregisterTemporaryReportCheck ¶ added in v0.5.7
func UnregisterTemporaryReportCheck(name string)
func UpdateHealthzState ¶ added in v0.4.1
func UpdateHealthzState(name string, state HealthzCheckState, message string) error
func UpdateHealthzStateByError ¶ added in v0.4.1
func WarningfPath ¶ added in v0.3.0
func WarningfPath(pkg LoggingPKG, message string, params ...interface{})
Types ¶
type CappedSmoothWindow ¶
type CappedSmoothWindow struct { sync.Mutex SmoothWindow // contains filtered or unexported fields }
func NewCappedSmoothWindow ¶
func NewCappedSmoothWindow(minStep resource.Quantity, maxStep resource.Quantity, smoothWindow SmoothWindow) *CappedSmoothWindow
NewCappedSmoothWindow creates a capped SmoothWindow, which
func (*CappedSmoothWindow) GetWindowedResources ¶
func (m *CappedSmoothWindow) GetWindowedResources(value resource.Quantity) *resource.Quantity
GetWindowedResources cap the value return by smooth window min to max
type CommonSuffixTranslator ¶ added in v0.5.4
type CommonSuffixTranslator struct {
// contains filtered or unexported fields
}
func NewCommonSuffixTranslator ¶ added in v0.5.4
func NewCommonSuffixTranslator(suffix string) *CommonSuffixTranslator
func (*CommonSuffixTranslator) Translate ¶ added in v0.5.4
func (cs *CommonSuffixTranslator) Translate(s string) string
type FileWatcherInfo ¶
type Flock ¶
type Flock struct { LockFile string // contains filtered or unexported fields }
func GetUniqueLock ¶
GetUniqueLock is a wrapper function for getUniqueLockWithTimeout with default configurations
type HealthzCheckFunc ¶ added in v0.2.0
type HealthzCheckFunc func() (healthzCheckStatus, error)
HealthzCheckFunc defined as a common function to define whether the corresponding component is healthy.
type HealthzCheckMode ¶ added in v0.4.1
type HealthzCheckMode string
type HealthzCheckName ¶ added in v0.2.0
type HealthzCheckName string
HealthzCheckName describes which rule name for this check
type HealthzCheckResult ¶ added in v0.4.1
type HealthzCheckState ¶ added in v0.2.0
type HealthzCheckState string
HealthzCheckState describes the checking results
type Logger ¶ added in v0.2.0
type Logger struct {
// contains filtered or unexported fields
}
func LoggerWithPrefix ¶ added in v0.2.0
func LoggerWithPrefix(prefix string, pkg LoggingPKG) Logger
type LoggingPKG ¶ added in v0.2.0
type LoggingPKG int
const ( LoggingPKGNone LoggingPKG = iota LoggingPKGShort LoggingPKGFull )
func (*LoggingPKG) Set ¶ added in v0.3.0
func (l *LoggingPKG) Set(value string) error
func (*LoggingPKG) String ¶ added in v0.3.0
func (l *LoggingPKG) String() string
func (*LoggingPKG) Type ¶ added in v0.3.0
func (l *LoggingPKG) Type() string
type MultiSorter ¶
type MultiSorter struct {
// contains filtered or unexported fields
}
MultiSorter implements the Sort interface, sorting changes within.
func NewMultiSorter ¶
func NewMultiSorter(cmp ...CmpFunc) *MultiSorter
NewMultiSorter returns a Sorter that sorts using the cmp functions, in order. Call its Sort method to sort the data.
func (*MultiSorter) Sort ¶
func (ms *MultiSorter) Sort(sources SourceList)
Sort sorts the argument slice according to the Less functions passed to NewMultiSorter.
type Pair ¶ added in v0.2.0
func SortedByValue ¶ added in v0.5.5
type ResourceList ¶
type ResourceList v1.ResourceList
func (*ResourceList) Set ¶
func (r *ResourceList) Set(value string) error
func (*ResourceList) String ¶
func (r *ResourceList) String() string
func (*ResourceList) Type ¶
func (r *ResourceList) Type() string
type SmoothWindow ¶
type SmoothWindow interface { // GetWindowedResources receives a sample and returns the result after smoothing, // it can return nil if there are not enough samples in this window GetWindowedResources(value resource.Quantity) *resource.Quantity Empty() bool }
SmoothWindow is used to smooth the resource
func NewAggregatorSmoothWindow ¶ added in v0.3.0
func NewAggregatorSmoothWindow(opts SmoothWindowOpts) SmoothWindow
func NewAverageWithTTLSmoothWindow ¶
func NewAverageWithTTLSmoothWindow(windowSize int, ttl time.Duration, usedMillValue bool) SmoothWindow
NewAverageWithTTLSmoothWindow create a smooth window with ttl and window size, and the window size is the sample count while the ttl is the valid lifetime of each sample, and the usedMillValue means whether calculate the result with milli-value.
func NewPercentileWithTTLSmoothWindow ¶ added in v0.3.0
func NewPercentileWithTTLSmoothWindow(windowSize int, ttl time.Duration, percentile float64, usedMillValue bool) SmoothWindow
NewPercentileWithTTLSmoothWindow create a smooth window with ttl and window size, and the window size is the sample count while the ttl is the valid lifetime of each sample, and the usedMillValue means whether calculate the result with milli-value.
type SmoothWindowOpts ¶ added in v0.3.0
type SourceList ¶
type TTLSmoothWindow ¶ added in v0.4.0
func NewTTLSmoothWindow ¶ added in v0.4.0
func NewTTLSmoothWindow(windowSize int, ttl time.Duration, usedMillValue bool) *TTLSmoothWindow
func (*TTLSmoothWindow) Empty ¶ added in v0.4.0
func (w *TTLSmoothWindow) Empty() bool