utils

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: GPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Bool = map[bool]string{
			// contains filtered or unexported fields
	}
	NotificationStatesToInt = map[string]int{
		"OK":       1,
		"Warning":  2,
		"Critical": 4,
		"Unknown":  8,
		"Up":       16,
		"Down":     32,
	}
	NotificationTypesToInt = map[string]int{
		"DowntimeStart":   1,
		"DowntimeEnd":     2,
		"DowntimeRemoved": 4,
		"Custom":          8,
		"Acknowledgement": 16,
		"Problem":         32,
		"Recovery":        64,
		"FlappingStart":   128,
		"FlappingEnd":     256,
	}
	NotificationTypesToDbEnumString = map[string]string{
		"1":   "downtime_start",
		"2":   "downtime_end",
		"4":   "downtime_removed",
		"8":   "custom",
		"16":  "acknowledgement",
		"32":  "problem",
		"64":  "recovery",
		"128": "flapping_start",
		"256": "flapping_end",
	}
	CommentEntryTypes = map[string]string{
		"1": "comment",
		"4": "ack",
	}
)

Functions

func Checksum

func Checksum(s string) string

Checksum converts the given string into a SHA1 checksum string.

func ChunkKeys

func ChunkKeys(done <-chan struct{}, keys []string, size int) <-chan []string

func DecodeChecksum

func DecodeChecksum(c []byte) string

DecodeChecksum coverts a byte array into a hex string.

func DecodeHexIfNotNil

func DecodeHexIfNotNil(hexStr interface{}) interface{}

DecodeHexIfNotNil converts a hex string to a byte array.

func DefaultIfNil

func DefaultIfNil(value, defaultValue interface{}) interface{}

DefaultIfNil returns a defaultValue, if the given value is nil

func Delta

func Delta(a []string, b []string) ([]string, []string, []string)

func EncodeChecksum

func EncodeChecksum(s string) []byte

EncodeChecksum converts a hex string to a byte array.

func IcingaStateTypeToString

func IcingaStateTypeToString(stateType float32) string

func JSONBooleanToDBBoolean

func JSONBooleanToDBBoolean(value interface{}) string

JSONBooleanToDBBoolean converts a boolean we got from Redis into a DB boolean.

func MillisecsToTime

func MillisecsToTime(millis float64) time.Time

func NotificationStatesToBitMask

func NotificationStatesToBitMask(states []string) int

NotificationStatesToBitMask converts an array of notification state strings into a bit mask.

func NotificationTypesToBitMask

func NotificationTypesToBitMask(types []string) int

NotificationTypesToBitMask converts an array of notification type strings into a bit mask.

func RedisIntToDBBoolean

func RedisIntToDBBoolean(value interface{}) string

func TimeToFloat

func TimeToFloat(t time.Time) float64

func TimeToMillisecs

func TimeToMillisecs(t time.Time) int64

TimeToMillisecs returns t as ms since *nix epoch.

Types

type Benchmark

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

Benchmark is a stopwatch for benchmarking.

func NewBenchmark

func NewBenchmark() *Benchmark

NewBenchmark constructs and starts a Benchmark.

func (*Benchmark) MarshalText

func (b *Benchmark) MarshalText() (text []byte, err error)

MarshalText implements an interface from TextMarshaler.

func (*Benchmark) Seconds

func (b *Benchmark) Seconds() float64

Seconds returns the measured time in seconds.

func (*Benchmark) Stop

func (b *Benchmark) Stop()

Stop stops the stopwatch.

func (*Benchmark) String

func (b *Benchmark) String() string

String renders the measured time human-readably.

Jump to

Keyboard shortcuts

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