utils

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0, MIT, MPL-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const B uint64 = UNIT
View Source
const BinaryDataMagnitude uint64 = 1024
View Source
const UNIT uint64 = 1

Variables

View Source
var DeprecatedTags = map[string]string{
	"enable-streaming": "EnableStreaming",
}

Functions

func AddHeaders added in v1.4.0

func AddHeaders(exist http.Header, addons []string)

AddHeaders parse headers like "a: b" and add them to exist header

func CollectLog

func CollectLog(collector, home, user, instanceID, inspectionID string, begin, end time.Time) error

CollectLog collects logs

func DirSize

func DirSize(dir string) (int64, error)

DirSize returns the total file size of a dir

func ElemInRange

func ElemInRange(value reflect.Value, l int64, h int64) bool

func FlatMap

func FlatMap(value reflect.Value, tagPath string) reflect.Value

FlatMap iterate all map element with the given tagPath, return a slice contain all visited elements. the given value should be a map type.

func Len

func Len(value reflect.Value) int

func MustCmpDuration

func MustCmpDuration(left string, right string) int

MustCmpDuration return 0, -1, 1; 0 left == right, 1 left > right, -1 left < right Only use this method in gengine

func MustCmpReadableSize

func MustCmpReadableSize(left string, right string) int

MustCmpReadableSize return 0, -1, 1; 0 left == right, 1 left > right, -1 left < right Only use this method in gengine

func ParseReadableDuration

func ParseReadableDuration(s string) (time.Duration, error)

ParseReadableDuration is copied from prometheus ParseDuration function.

func ParseTime

func ParseTime(s string) (time.Time, error)

ParseTime converts a string to time.Time, ported from Prometheus: web/api/v1/api.go

func RecursiveIfBoolValueExist

func RecursiveIfBoolValueExist(reflectV reflect.Value, value bool) bool

func RecursiveSetBoolValue

func RecursiveSetBoolValue(reflectV reflect.Value, value bool)

func RunPortForward added in v1.4.0

func RunPortForward(kubeconfig, namespace, podName string, port int) (stopChannel chan struct{}, localPort int, err error)

func TrimLeftSpace added in v1.4.0

func TrimLeftSpace(s string) string

TrimLeftSpace trim all left space

func ValueToBool

func ValueToBool(value reflect.Value) bool

func ValueToFloat

func ValueToFloat(value reflect.Value) float64

func ValueToInt

func ValueToInt(value reflect.Value) int64

func ValueToString

func ValueToString(value reflect.Value) string

ValueToString return the parsed string value for other type

func VisitByTagPath

func VisitByTagPath(node reflect.Value, tags []string, idx int) reflect.Value

Types

type ReadableSize

type ReadableSize = uint64

func ParseReadableSize

func ParseReadableSize(s string) (ReadableSize, error)

type Token

type Token struct {
}

Token is used as a permission to keep on running.

type TokenLimiter

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

TokenLimiter is used to limit the number of concurrent tasks.

func NewTokenLimiter

func NewTokenLimiter(count uint) *TokenLimiter

NewTokenLimiter creates a TokenLimiter with count tokens.

func (*TokenLimiter) Get

func (tl *TokenLimiter) Get() *Token

Get obtains a token.

func (*TokenLimiter) Put

func (tl *TokenLimiter) Put(tk *Token)

Put releases the token.

func (*TokenLimiter) Wait

func (tl *TokenLimiter) Wait()

Wait all token put back

Directories

Path Synopsis
tagd-value

Jump to

Keyboard shortcuts

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