metrictank: github.com/grafana/metrictank/util Index | Files | Directories

package util

import "github.com/grafana/metrictank/util"

Index

Package Files

atomic.go buffer_pool.go combinations.go compression.go flag_parsers.go flags.go fnv32a.go fnv64a.go helper.go limiter.go naturalsort.go template.go timeout.go util.go

func AllCombinationsUint32 Uses

func AllCombinationsUint32(parts [][]uint32) (out [][]uint32)

AllCombinationsUint32 returns all combinations of the input

func AtomicBumpInt64 Uses

func AtomicBumpInt64(loc *int64, newVal int64)

AtomicBumpInt64 assures the given address stores the highest int64 between the current value, the value provided and the value provided by any other concurrently executing call

func AtomicBumpUint32 Uses

func AtomicBumpUint32(loc *uint32, newVal uint32)

AtomicBumpUint32 assures the given address stores the highest uint32 between the current value, the value provided and the value provided by any other concurrently executing call

func DecompressGzip Uses

func DecompressGzip(r io.Reader) (string, error)

func IsDigit Uses

func IsDigit(r byte) bool

func Lcm Uses

func Lcm(vals []uint32) uint32

Lcm returns the least common multiple

func Max Uses

func Max(a, b uint32) uint32

func MaxInt Uses

func MaxInt(a, b int) int

func Min Uses

func Min(a, b uint32) uint32

func NaturalLess Uses

func NaturalLess(s, t string) bool

NaturalLess compares strings lexicographically *except* substrings of numbers are sorted numerically

func ParseIngestFromFlags Uses

func ParseIngestFromFlags(ingestFromStr string) (map[uint32]int64, error)

func ReadEntry Uses

func ReadEntry(TomlFilename string, EntryName string) interface{}

func RegisterFlags Uses

func RegisterFlags(rs ...Registerer)

RegisterFlags registers flags with the provided Registerers

func TS Uses

func TS(ts interface{}) string

func TimeBoundWithCacheFunc Uses

func TimeBoundWithCacheFunc(fn func() interface{}, timeout, maxAge time.Duration) func() interface{}

TimeBoundWithCacheFunc decorates a function that has a return value in order to bound its execution time. When the decorated function is called, if the original function takes more than 'timeout' to execute, the returned value will be the value returned by a previous call. If no previous call was performed, the call will block until the original function returns.

type BufferPool Uses

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

func NewBufferPool Uses

func NewBufferPool() *BufferPool

func (*BufferPool) Get Uses

func (b *BufferPool) Get() []byte

func (*BufferPool) Put Uses

func (b *BufferPool) Put(buf []byte)

type BufferPool33 Uses

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

BufferPool33 is a pool that returns cap=33 len=0 byte slices

func NewBufferPool33 Uses

func NewBufferPool33() *BufferPool33

func (*BufferPool33) Get Uses

func (b *BufferPool33) Get() []byte

func (*BufferPool33) Put Uses

func (b *BufferPool33) Put(buf []byte)

type Int64SliceFlag Uses

type Int64SliceFlag []int64

func (*Int64SliceFlag) Set Uses

func (i *Int64SliceFlag) Set(value string) error

func (*Int64SliceFlag) String Uses

func (i *Int64SliceFlag) String() string

type Limiter Uses

type Limiter chan struct{}

Limiter provides a mechanism for limiting concurrency. Users need to call Acquire() before starting work and Release() when the work is done. Acquire() will block if the Limiters limit has already been reached and unblock when another thread calls Release(), or the passed context is canceled.

func NewLimiter Uses

func NewLimiter(l int) Limiter

NewLimiter creates a limiter with l slots

func (Limiter) Acquire Uses

func (l Limiter) Acquire(ctx context.Context) bool

Acquire returns when a slot is available. If the limit is reached it will block until another thread calls Release() or the context is done. In the latter case we return false.

func (Limiter) Release Uses

func (l Limiter) Release()

type NaturalSortStringSlice Uses

type NaturalSortStringSlice []string

NaturalSortStringSlice sorts strings lexicographically *except* substrings of numbers are sorted numerically

func (NaturalSortStringSlice) Len Uses

func (ss NaturalSortStringSlice) Len() int

func (NaturalSortStringSlice) Less Uses

func (ss NaturalSortStringSlice) Less(i, j int) bool

func (NaturalSortStringSlice) Swap Uses

func (ss NaturalSortStringSlice) Swap(i, j int)

type Registerer Uses

type Registerer interface {
    RegisterFlags(*flag.FlagSet)
}

Registerer is a thing that can RegisterFlags

type StringHash32 Uses

type StringHash32 interface {
    hash.Hash32
    WriteString(string) (int, error)
}

func NewFnv32aStringWriter Uses

func NewFnv32aStringWriter() StringHash32

type StringHash64 Uses

type StringHash64 interface {
    hash.Hash64
    WriteString(string) (int, error)
}

func NewFnv64aStringWriter Uses

func NewFnv64aStringWriter() StringHash64

type Sum32aStringWriter Uses

type Sum32aStringWriter uint32

Sum32aStringWriter is mostly a copy of fnv.sum32a the only difference is the additional method WriteString(), due to this additional method it satisfies the io.StringWriter interface which can prevent unnecessary conversions to/from byte slices

func (*Sum32aStringWriter) BlockSize Uses

func (s *Sum32aStringWriter) BlockSize() int

func (*Sum32aStringWriter) Reset Uses

func (s *Sum32aStringWriter) Reset()

func (*Sum32aStringWriter) Size Uses

func (s *Sum32aStringWriter) Size() int

func (*Sum32aStringWriter) Sum Uses

func (s *Sum32aStringWriter) Sum(in []byte) []byte

func (*Sum32aStringWriter) Sum32 Uses

func (s *Sum32aStringWriter) Sum32() uint32

func (*Sum32aStringWriter) Write Uses

func (s *Sum32aStringWriter) Write(data []byte) (int, error)

func (*Sum32aStringWriter) WriteString Uses

func (s *Sum32aStringWriter) WriteString(data string) (int, error)

type Sum64aStringWriter Uses

type Sum64aStringWriter uint64

Sum64aStringWriter is mostly a copy of fnv.sum64a the only difference is the additional method WriteString(), due to this additional method it satisfies the io.StringWriter interface which can prevent unnecessary conversions to/from byte slices

func (*Sum64aStringWriter) BlockSize Uses

func (s *Sum64aStringWriter) BlockSize() int

func (*Sum64aStringWriter) Reset Uses

func (s *Sum64aStringWriter) Reset()

func (*Sum64aStringWriter) Size Uses

func (s *Sum64aStringWriter) Size() int

func (*Sum64aStringWriter) Sum Uses

func (s *Sum64aStringWriter) Sum(in []byte) []byte

func (*Sum64aStringWriter) Sum64 Uses

func (s *Sum64aStringWriter) Sum64() uint64

func (*Sum64aStringWriter) Write Uses

func (s *Sum64aStringWriter) Write(data []byte) (int, error)

func (*Sum64aStringWriter) WriteString Uses

func (s *Sum64aStringWriter) WriteString(data string) (int, error)

Directories

PathSynopsis
align

Package util imports 16 packages (graph) and is imported by 50 packages. Updated 2020-07-11. Refresh now. Tools for package owners.