util

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlterPartitionReassignmentsRequestAssignmentError added in v1.8.1

func AlterPartitionReassignmentsRequestAssignmentError(results []kafka.AlterPartitionReassignmentsResponsePartitionResult) error

func CanTestBrokerAdmin added in v1.0.0

func CanTestBrokerAdmin() bool

CanTestBrokerAdmin returns whether we can test the broker-only admin client.

func CanTestBrokerAdminSecurity added in v1.10.3

func CanTestBrokerAdminSecurity() bool

CanTestBrokerAdminSecurity returns whether we can test the broker-only admin client security features.

func Confirm added in v1.12.0

func Confirm(prompt string, skip bool) (bool, error)

Confirm shows the argument prompt to the user and returns a boolean based on whether or not the user confirms that it's ok to continue.

func CopyInts

func CopyInts(input []int) []int

CopyInts copies a slice of ints.

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 IncrementalAlterConfigsResponseResourcesError added in v1.7.0

func IncrementalAlterConfigsResponseResourcesError(resources []kafka.IncrementalAlterConfigsResponseResource) error

func KafkaErrorsToErr added in v1.7.0

func KafkaErrorsToErr(errors map[string]error) error

func PrettyDuration

func PrettyDuration(duration time.Duration) string

PrettyDuration returns a human-formatted duration string given an golang duration value.

func PrettyRate

func PrettyRate(count int64, duration time.Duration) string

PrettyRate returns a human-formatted rate from a count and a duration.

func RandomString

func RandomString(prefix string, length int) string

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

func RetryUntil(t *testing.T, timeout time.Duration, f func() error)

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

func SameElements(slice1 []int, slice2 []int) bool

SameElements determines whether two int slices have the same elements (in any order).

func ShowProgress added in v1.10.1

func ShowProgress(
	ctx context.Context,
	progressConfig interface{},
	interval time.Duration,
	stopChan chan bool,
)

shows progress of a config repeatedly during an interval

func ShuffledKeys

func ShuffledKeys(input map[int]int, seedStr string) []int

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

func SortedKeys(input map[int]int) []int

SortedKeys returns the keys of the argument, sorted by value.

func SortedKeysByValue

func SortedKeysByValue(input map[int]int, asc bool, keySorter KeySorter) []int

SortedKeysByValue returns the keys in a map, sorted by the map values.

func StructToStr added in v1.10.1

func StructToStr(inputStruct interface{}) (string, error)

Convert any struct to json string

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

func TruncateStringMiddle(input string, maxLen int, suffixLen int) (string, int)

TruncateStringMiddle truncates a string by replacing characters in the middle with "..." if needed.

func TruncateStringSuffix

func TruncateStringSuffix(input string, maxLen int) (string, int)

TruncateStringSuffix truncates a string by replacing the trailing characters with "..." if needed.

Types

type KeySorter

type KeySorter func(map[int]int) []int

KeySorter is a type for a function that sorts integer keys based on their values in a map.

type RebalanceCtxStruct added in v1.10.1

type RebalanceCtxStruct struct {
	Enabled  bool          `json:"enabled"`
	Interval time.Duration `json:"interval"`
}

Rebalance context struct

type RebalanceProgressConfig added in v1.10.1

type RebalanceProgressConfig struct {
	SuccessTopics      int    `json:"success_topics"`
	ErrorTopics        int    `json:"error_topics"`
	ClusterName        string `json:"cluster"`
	ClusterEnvironment string `json:"environment"`
	ToRemove           []int  `json:"to_remove"`
}

Rebalance overall progress Config

type RebalanceRoundProgressConfig added in v1.10.1

type RebalanceRoundProgressConfig struct {
	TopicName          string `json:"topic"`
	ClusterName        string `json:"cluster"`
	ClusterEnvironment string `json:"environment"`
	ToRemove           []int  `json:"to_remove"`
	CurrRound          int    `json:"round"`
	TotalRounds        int    `json:"total_rounds"`
}

Rebalance Topic Round progress Config

type RebalanceTopicProgressConfig added in v1.10.1

type RebalanceTopicProgressConfig struct {
	TopicName          string `json:"topic"`
	ClusterName        string `json:"cluster"`
	ClusterEnvironment string `json:"environment"`
	ToRemove           []int  `json:"to_remove"`
	RebalanceError     bool   `json:"rebalance_error"`
}

Rebalance topic progress Config

Jump to

Keyboard shortcuts

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