util

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyLibrdkafkaConf

func ApplyLibrdkafkaConf(config map[string]string, configMap *kafka.ConfigMap) error

ApplyLibrdkafkaConf overlays librdkafka config values from the provided firebolt config onto the consumer config; in the firebolt config these should be key prefixed with 'librdkafka.' and here we remove the prefix and pass 'em through https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md

func AwaitCondition

func AwaitCondition(cond Condition, period time.Duration, maxWait time.Duration) error

AwaitCondition runs the passed 'cond' function every period until it returns true, returning an error if maxWait is exceeded.

func BuildInstanceID

func BuildInstanceID() string

BuildInstanceID creates a unique ID for this instance of the running application by appending the host IP address and a random string.

func GetCounterValue

func GetCounterValue(counter prometheus.Counter) (float64, error)

GetCounterValue fetches the current value of a prometheus counter. This is inherently racy and intended for test use only.

func GetCounterVecValue

func GetCounterVecValue(counterVec *prometheus.CounterVec, lvs ...string) (float64, error)

GetCounterVecValue fetches the current value of a prometheus contervec for the passed label values. This is inherently racy and intended for test use only.

func GetGaugeValue

func GetGaugeValue(gauge prometheus.Gauge) (float64, error)

GetGaugeValue fetches the current value of a prometheus gauge. This is inherently racy and intended for test use only.

func GetGaugeVecValue

func GetGaugeVecValue(gaugeVec *prometheus.GaugeVec, lvs ...string) (float64, error)

GetGaugeVecValue fetches the current value of a prometheus gaugevec for the passed label values. This is inherently racy and intended for test use only.

func GetIPAddress

func GetIPAddress() (string, error)

GetIPAddress finds and returns the first non-loopback IP address formatted as a string.

func RandString

func RandString(n int) string

RandString creates and returns a pseudorandom string from randAlphabet of length n.

func WaitForPort

func WaitForPort(t *testing.T, port int) error

WaitForPort waits for the passed port number to start accepting connections. This can be used in integration tests to ensure that infrastructure services are available before tests that depend on them start to run. It's necessary because docker-compose returns when the configured containers are created, which doesn't ensure that the services they run are ready.d

Types

type Condition

type Condition func() bool

Condition is a function that returns a boolean indicating whether to stop waiting

Jump to

Keyboard shortcuts

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