util

package
v0.0.0-...-26ee178 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsConnCanceled

func IsConnCanceled(err error) bool

IsConnCanceled returns true, if error is from a closed gRPC connection. copied from https://github.com/etcd-io/etcd/blob/7f47de84146bdc9225d2080ec8678ca8189a2d2b/clientv3/client.go#L646

func LabelsToMetric

func LabelsToMetric(ls labels.Labels) model.Metric

LabelsToMetric converts a Labels to Metric Don't do this on any performance sensitive paths.

func LogConfig

func LogConfig(cfg interface{}) error

LogConfig takes a pointer to a config object, marshalls it to YAML and prints each line in REVERSE order The reverse order makes display in Plutono in easier which typically sorts newest entries at the top.

func MapToModelLabelSet

func MapToModelLabelSet(m map[string]string) model.LabelSet

MapToModelLabelSet converts a map into a model.LabelSet

func MergeStringLists

func MergeStringLists(ss ...[]string) []string

func MergeStringPair

func MergeStringPair(s1, s2 []string) []string

func ModelLabelSetToMap

func ModelLabelSetToMap(m model.LabelSet) map[string]string

ModelLabelSetToMap convert a model.LabelSet to a map[string]string

func PrintConfig

func PrintConfig(w io.Writer, config interface{}) error

PrintConfig will takes a pointer to a config object, marshalls it to YAML and prints the result to the provided writer unlike LogConfig, PrintConfig prints the object in naturally ocurring order.

func RoundToMilliseconds

func RoundToMilliseconds(from, through time.Time) (model.Time, model.Time)

RoundToMilliseconds returns milliseconds precision time from nanoseconds. from will be rounded down to the nearest milliseconds while through is rounded up.

func SnakeCase

func SnakeCase(s string) string

SnakeCase converts given string `s` into `snake_case`.

func StringRef

func StringRef(value string) *string

func StringSliceContains

func StringSliceContains(slice []string, value string) bool

func TokenFor

func TokenFor(userID, labels string) uint32

TokenFor generates a token used for finding ingesters from ring

Types

type ExtendedMock

type ExtendedMock struct {
	mock.Mock
}

func (*ExtendedMock) GetMockedCallsByMethod

func (m *ExtendedMock) GetMockedCallsByMethod(method string) []mock.Call

type LogAdapter

type LogAdapter struct {
	log.Logger
}

func NewLogAdapter

func NewLogAdapter(l log.Logger) LogAdapter

func (LogAdapter) Fatal

func (l LogAdapter) Fatal(v ...interface{})

Fatal implements tail.logger

func (LogAdapter) Fatalf

func (l LogAdapter) Fatalf(format string, v ...interface{})

Fatalf implements tail.logger

func (LogAdapter) Fatalln

func (l LogAdapter) Fatalln(v ...interface{})

Fatalln implements tail.logger

func (LogAdapter) Panic

func (l LogAdapter) Panic(v ...interface{})

Panic implements tail.logger

func (LogAdapter) Panicf

func (l LogAdapter) Panicf(format string, v ...interface{})

Panicf implements tail.logger

func (LogAdapter) Panicln

func (l LogAdapter) Panicln(v ...interface{})

Panicln implements tail.logger

func (LogAdapter) Print

func (l LogAdapter) Print(v ...interface{})

Print implements tail.logger

func (LogAdapter) Printf

func (l LogAdapter) Printf(format string, v ...interface{})

Printf implements tail.logger

func (LogAdapter) Println

func (l LogAdapter) Println(v ...interface{})

Println implements tail.logger

type MultiError

type MultiError []error

The MultiError type implements the error interface, and contains the Errors used to construct it.

func (*MultiError) Add

func (es *MultiError) Add(err error)

Add adds the error to the error list if it is not nil.

func (MultiError) Err

func (es MultiError) Err() error

Err returns the error list as an error or nil if it is empty.

func (MultiError) Error

func (es MultiError) Error() string

Returns a concatenated string of the contained errors

func (MultiError) Is

func (es MultiError) Is(target error) bool

Is tells if all errors are the same as the target error.

type QueryStringBuilder

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

func NewQueryStringBuilder

func NewQueryStringBuilder() *QueryStringBuilder

func (*QueryStringBuilder) Encode

func (b *QueryStringBuilder) Encode() string

Encode returns the URL-encoded query string based on key-value parameters added to the builder calling Set functions.

func (*QueryStringBuilder) SetFloat

func (b *QueryStringBuilder) SetFloat(name string, value float64)

func (*QueryStringBuilder) SetFloat32

func (b *QueryStringBuilder) SetFloat32(name string, value float32)

func (*QueryStringBuilder) SetInt

func (b *QueryStringBuilder) SetInt(name string, value int64)

func (*QueryStringBuilder) SetInt32

func (b *QueryStringBuilder) SetInt32(name string, value int)

func (*QueryStringBuilder) SetString

func (b *QueryStringBuilder) SetString(name, value string)

func (*QueryStringBuilder) SetStringArray

func (b *QueryStringBuilder) SetStringArray(name string, values []string)

type SizeReader

type SizeReader interface {
	io.Reader
	Size() int64
}

func NewSizeReader

func NewSizeReader(r io.Reader) SizeReader

NewSizeReader returns an io.Reader that will have the number of bytes read from r available.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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