util

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: Apache-2.0 Imports: 23 Imported by: 259

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsConnCanceled added in v0.4.0

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 added in v0.4.0

func LabelsToMetric(ls labels.Labels) model.Metric

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

func LogConfig added in v1.6.0

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 Grafana in easier which typically sorts newest entries at the top.

func MergeStringLists added in v1.5.0

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

func MergeStringPair added in v1.5.0

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 added in v1.6.0

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 added in v0.2.0

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 StringRef added in v0.4.0

func StringRef(value string) *string

func StringSliceContains added in v0.4.0

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

func ToClientLabels

func ToClientLabels(labels string) ([]client.LabelAdapter, error)

ToClientLabels parses the labels and converts them to the Cortex type.

func TokenFor added in v0.2.0

func TokenFor(userID, labels string) uint32

TokenFor generates a token used for finding ingesters from ring

Types

type ExtendedMock added in v0.2.0

type ExtendedMock struct {
	mock.Mock
}

func (*ExtendedMock) GetMockedCallsByMethod added in v0.2.0

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

type LogAdapter added in v1.5.0

type LogAdapter struct {
	log.Logger
}

func NewLogAdapter added in v1.5.0

func NewLogAdapter(l log.Logger) LogAdapter

func (LogAdapter) Fatal added in v1.5.0

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

Fatal implements tail.logger

func (LogAdapter) Fatalf added in v1.5.0

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

Fatalf implements tail.logger

func (LogAdapter) Fatalln added in v1.5.0

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

Fatalln implements tail.logger

func (LogAdapter) Panic added in v1.5.0

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

Panic implements tail.logger

func (LogAdapter) Panicf added in v1.5.0

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

Panicf implements tail.logger

func (LogAdapter) Panicln added in v1.5.0

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

Panicln implements tail.logger

func (LogAdapter) Print added in v1.5.0

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

Print implements tail.logger

func (LogAdapter) Printf added in v1.5.0

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

Printf implements tail.logger

func (LogAdapter) Println added in v1.5.0

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

type QueryStringBuilder added in v0.4.0

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

func NewQueryStringBuilder added in v0.4.0

func NewQueryStringBuilder() *QueryStringBuilder

func (*QueryStringBuilder) Encode added in v0.4.0

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 added in v0.4.0

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

func (*QueryStringBuilder) SetFloat32 added in v0.4.0

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

func (*QueryStringBuilder) SetInt added in v0.4.0

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

func (*QueryStringBuilder) SetInt32 added in v0.4.0

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

func (*QueryStringBuilder) SetString added in v0.4.0

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

func (*QueryStringBuilder) SetStringArray added in v1.5.0

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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