types_convertation

package
v0.0.0-...-d77dacb Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = 1000
	MB = 1000 * KB
	GB = 1000 * MB
	TB = 1000 * GB
	PB = 1000 * TB

	KiB = 1024
	MiB = 1024 * KiB
	GiB = 1024 * MiB
	TiB = 1024 * GiB
	PiB = 1024 * TiB
)

See: http://en.wikipedia.org/wiki/Binary_prefix

Variables

View Source
var (
	TimeIsEmptyOrZero = errors.New("time parameter is empty or zero")
)

Functions

func AdaptMetricsSliceFromProto

func AdaptMetricsSliceFromProto(in []enums.MetricsType) (out []customtypes.ScaleSourceMetrics)

func AdaptMetricsSliceToProto

func AdaptMetricsSliceToProto(in []customtypes.ScaleSourceMetrics) (out []enums.MetricsType)

func AdaptPbTimestampToTime

func AdaptPbTimestampToTime(protoTime *tspb.Timestamp) (*time.Time, error)

func AdaptPeriodSliceFromProto

func AdaptPeriodSliceFromProto(in []enums.PeriodType) (out []customtypes.ScaleSourcePeriod)

func AdaptPeriodSliceToProto

func AdaptPeriodSliceToProto(in []customtypes.ScaleSourcePeriod) (out []enums.PeriodType)

func AdaptResourceKindSliceFromProto

func AdaptResourceKindSliceFromProto(in []enums.ResourceType) (out []customtypes.ScaleResourceKind)

func AdaptResourceKindSliceToProto

func AdaptResourceKindSliceToProto(in []customtypes.ScaleResourceKind) (out []enums.ResourceType)

func AdaptTimeToPbTimestamp

func AdaptTimeToPbTimestamp(currentTime *time.Time) (*tspb.Timestamp, error)

func BytesSize

func BytesSize(size float64) string

BytesSize returns a human-readable size in bytes, kibibytes, mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").

func ConvertProviderEvent

func ConvertProviderEvent(in v2.AIPodAutoscalerSpec) (out *pb.ReqGetMetrics)

func CustomSize

func CustomSize(format string, size float64, base float64, _map []string) string

CustomSize returns a human-readable approximation of a size using custom format.

func FromHumanSize

func FromHumanSize(size string) (int64, error)

FromHumanSize returns an integer from a human-readable specification of a size using SI standard (eg. "44kB", "17MB").

func HumanSize

func HumanSize(size float64) string

HumanSize returns a human-readable approximation of a size capped at 4 valid numbers (eg. "2.746 MB", "796 KB").

func HumanSizeWithPrecision

func HumanSizeWithPrecision(size float64, precision int) string

HumanSizeWithPrecision allows the size to be in any precision, instead of 4 digit precision used in units.HumanSize.

func Int32

func Int32(v int32) *int32

func Int32Ptr

func Int32Ptr(v *int32) int32

func RAMInBytes

func RAMInBytes(size string) (int64, error)

RAMInBytes parses a human-readable string representing an amount of RAM in bytes, kibibytes, mebibytes, gibibytes, or tebibytes and returns the number of bytes, or -1 if the string is unparseable. Units are case-insensitive, and the 'b' suffix is optional.

func String

func String(v string) *string

func StringPtr

func StringPtr(v *string) string

func TimePtrToTime

func TimePtrToTime(t *time.Time) (emptyTime time.Time)

func TimeToTimePtr

func TimeToTimePtr(t time.Time) *time.Time

Types

This section is empty.

Jump to

Keyboard shortcuts

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