utils

package
v0.0.0-...-17967aa Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHashCode

func GetHashCode(i interface{}) string

GetHashCode generates hashcode of given type

func GetLastChunkOfSlashed

func GetLastChunkOfSlashed(s string) string

GetLastChunkOfSlashed splits a string by slash and returns the last chunk.

func GetResourceKey

func GetResourceKey(namespace, name string) string

GetResourceKey generates the key in k8s format for a given resource

func ParseNamespacedName

func ParseNamespacedName(namespacedName string) (string, string, error)

func PrettyJSON

func PrettyJSON(js []byte, prefix string) ([]byte, error)

PrettyJSON Unmarshals and Marshall again with Indent so it is human readable

func RandStringRunes

func RandStringRunes(n int) string

RandStringRunes generates n length random string

func RemoveDuplicateStrings

func RemoveDuplicateStrings(list []string) []string

RemoveDuplicates returns a copy of a slice with duplicates removed

func Retry

func Retry(totalRetryCount int, retryPause time.Duration, retriableFunction RetriableFunction) (err error)

Retry retries retriableFunction for totalRetryCount times with a gap of retryPause. if retriableFunction returns boolean as false, then Retry will not retry and return error if retriableFunction returns boolean as true, then Retry will retry if fn returned an error if totalRetryCount is -1, then retry happen forever until one of the two above conditions are satisfied.

func SaveToFile

func SaveToFile(fileName string, content []byte) (string, error)

SaveToFile saves the content into a file named "fileName" - a tool primarily used for debugging purposes.

Types

type Retriable

type Retriable bool

Retriable is returned by RetriableFunction and tells whether to retry the function or not.

type RetriableFunction

type RetriableFunction func() (Retriable, error)

RetriableFunction is function that can be retried

type ThreadsafeMultiMap

type ThreadsafeMultiMap interface {
	Insert(key interface{}, value interface{})
	Clear(key interface{})
	Erase(key interface{}) bool
	EraseValue(value interface{}) bool
	ContainsPair(key interface{}, value interface{}) bool
	ContainsValue(value interface{}) bool
}

ThreadsafeMultiMap is a thread safe implementation of a multimap.

func NewThreadsafeMultimap

func NewThreadsafeMultimap() ThreadsafeMultiMap

NewThreadsafeMultimap creates a ThreadsafeMultiMap.

Jump to

Keyboard shortcuts

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