util

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2014 License: GPL-3.0 Imports: 8 Imported by: 16

Documentation

Index

Constants

View Source
const (
	TimestampFormat = "2006-01-02T15:04:05.000000Z"
)

Variables

View Source
var (
	LogInfo    = false
	LogDebug   = false
	LogVerbose = false
)

Functions

func Darwin

func Darwin() bool

func Debug

func Debug(msg string, args ...interface{})

-l debug: Verbosity level which helps track down production issues

func DebugDebug

func DebugDebug(msg string, args ...interface{})

-l verbose: Very verbose for development purposes

func FileExists

func FileExists(path string) (bool, error)

func Info

func Info(msg string, args ...interface{})

Typical logging output, the default level

func ReadLines

func ReadLines(data []byte) ([]string, error)

readLines reads a whole file into memory and returns a slice of its lines.

func SetLogLevel

func SetLogLevel(level string)

func Warn

func Warn(msg string, args ...interface{})

Uh oh, not good but not worthy of process death

Types

type RingBuffer

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

Metrics are stored in a RingBuffer so we can keep history while also keeping the total storage constant. You can add things to a RingBuffer but you cannot remove them. Older items will be overwritten and garbage collected in time.

func NewRingBuffer

func NewRingBuffer(capacity int) *RingBuffer

Return a RingBuffer with the given capacity.

func (*RingBuffer) Add

func (buf *RingBuffer) Add(elem float64)

Add the given element to the buffer. Method will panic if the caller tries to store nil.

func (*RingBuffer) At

func (buf *RingBuffer) At(idx int) *float64

Access the ring buffer based on previous elements added. 0 is the latest item, -1 is the previous one added, etc. This means that At(1) will give you the oldest item. Returns nil if the slot in the buffer has not been filled yet.

func (*RingBuffer) Capacity

func (buf *RingBuffer) Capacity() int

func (*RingBuffer) Export

func (buf *RingBuffer) Export() []float64

Export the set of values in the Ring Buffer, where the latest value will be last in the array. If the Buffer was not full, 0 will be exported.

func (*RingBuffer) Size

func (buf *RingBuffer) Size() int

Jump to

Keyboard shortcuts

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