Documentation
¶
Index ¶
- func CanTestBrokerAdmin() bool
- func CopyInts(input []int) []int
- func InTerminal() bool
- func PrettyDuration(duration time.Duration) string
- func PrettyRate(count int64, duration time.Duration) string
- func RandomString(prefix string, length int) string
- func RetryUntil(t *testing.T, timeout time.Duration, f func() error)
- func SameElements(slice1 []int, slice2 []int) bool
- func ShuffledKeys(input map[int]int, seedStr string) []int
- func SortedKeys(input map[int]int) []int
- func SortedKeysByValue(input map[int]int, asc bool, keySorter KeySorter) []int
- func TestKafkaAddr() string
- func TestZKAddr() string
- func TruncateStringMiddle(input string, maxLen int, suffixLen int) (string, int)
- func TruncateStringSuffix(input string, maxLen int) (string, int)
- type KeySorter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanTestBrokerAdmin ¶ added in v1.0.0
func CanTestBrokerAdmin() bool
CanTestBrokerAdmin returns whether we can test the broker-only admin client.
func InTerminal ¶
func InTerminal() bool
InTerminal determines whether we're running in a terminal or not.
Implementation from https://rosettacode.org/wiki/Check_output_device_is_a_terminal#Go.
func PrettyDuration ¶
PrettyDuration returns a human-formatted duration string given an golang duration value.
func PrettyRate ¶
PrettyRate returns a human-formatted rate from a count and a duration.
func RandomString ¶
RandomString returns a random string with the argument length.
Adapted from the example in https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-go.
func RetryUntil ¶ added in v1.0.0
RetryUntil is a helper that will re-run the argument function multiple times (up to a duration limit) until it no longer produces an error.
func SameElements ¶
SameElements determines whether two int slices have the same elements (in any order).
func ShuffledKeys ¶
ShuffledKeys returns a shuffled version of the keys in the argument map. The provided seedStr is hashed and used to seed the random number generator.
func SortedKeys ¶
SortedKeys returns the keys of the argument, sorted by value.
func SortedKeysByValue ¶
SortedKeysByValue returns the keys in a map, sorted by the map values.
func TestKafkaAddr ¶
func TestKafkaAddr() string
TestKafkaAddr returns a kafka bootstrap address for unit testing purposes.
func TestZKAddr ¶
func TestZKAddr() string
TestZKAddr returns a zookeeper address for unit testing purposes.
func TruncateStringMiddle ¶
TruncateStringMiddle truncates a string by replacing characters in the middle with "..." if needed.