Documentation ¶
Index ¶
- Constants
- func And(in ...bool) bool
- func ApplyMods[T any](in *T, mods ...Mod[T])
- func BoolSwitch[T interface{}](s bool, t, f T) T
- func CheckConditionalNil[T interface{}](in ConditionalFunction[T]) *T
- func CheckConditionalP1Nil[T, P1 interface{}](in ConditionalP1Function[T, P1], p1 P1) *T
- func ClientTLS(config *tls.Config) []grpc.DialOption
- func CompareInt(a, b int) bool
- func CompareInt64(a, b int64) bool
- func CompareInt64p(a, b *int64) bool
- func CompareIntp(a, b *int) bool
- func CompareJSON[T interface{}](a, b T) (bool, error)
- func CompareJSONP[T interface{}](a, b *T) (bool, error)
- func ContainsList[A comparable](in []A, item A) bool
- func CopyFullMap[K comparable, V any](src map[K]V) map[K]V
- func CopyList[A any](in []A) []A
- func CreateSignalContext(ctx context.Context) context.Context
- func Default[T interface{}]() T
- func DefaultInterface[T interface{}]() interface{}
- func ExtractLabel(obj meta.Object, label string) (string, bool)
- func First[T interface{}](input ...*T) *T
- func FirstNotDefault[T interface{}](input ...T) T
- func FlattenList[A any](in [][]A) []A
- func FormatList[A, B any](in []A, format func(A) B) []B
- func FormatListErr[A, B any](in []A, format func(A) (B, error)) ([]B, error)
- func InitOptional[T any](in *T, ok bool) *T
- func InitType[T interface{}](in *T) *T
- func IterateSorted[V any](m map[string]V, cb func(string, V))
- func JSONRemarshal[A, B any](in A) (B, error)
- func LastFromList[T interface{}](in []T) T
- func ListAsMap[K comparable, V any](in []V, extract func(in V) K) map[K]V
- func MD5(data []byte) string
- func MD5FromString(data string) string
- func MapKeys[K comparable, V any](m map[K]V) []K
- func MapValues[K comparable, V any](m map[K]V) []V
- func MergeMaps[K comparable, V any](override bool, maps ...map[K]V) map[K]V
- func NewGRPCClient[T any](ctx context.Context, in func(cc grpc.ClientConnInterface) T, addr string, ...) (T, io.Closer, error)
- func NewGRPCConn(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func NewOptionalTLSGRPCClient[T any](ctx context.Context, in func(cc grpc.ClientConnInterface) T, addr string, ...) (T, io.Closer, error)
- func NewOptionalTLSGRPCConn(ctx context.Context, addr string, tls *tls.Config, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func NewType[T interface{}](input T) *T
- func NewTypeOrNil[T interface{}](input *T) *T
- func NormalizeEnv(env string) string
- func OpenWithRead(path string, size int) ([]byte, error)
- func Optional[K comparable, V any](m map[K]V, key K, def V) V
- func OptionalType[T any](in *T, v T) T
- func Or(in ...bool) bool
- func ParallelThread(max int) (chan struct{}, func())
- func ParseAgencyTime(s string) (time.Time, bool)
- func ParseTime(s string, layouts ...string) (time.Time, int)
- func PickFromList[V any](in []V, q func(v V) bool) (V, bool)
- func Rand() *rand.Rand
- func RandomElement[T interface{}](in []T) (T, bool)
- func Read(in io.Reader, buff []byte) (int, error)
- func RunParallel(max int, actions ...func() error) error
- func SHA256(data []byte) string
- func SHA256FromExtract[T any](extract func(T) string, obj ...T) string
- func SHA256FromFile(file string) (string, error)
- func SHA256FromHashArray[T Hash](data []T) string
- func SHA256FromIO(in io.Reader) (string, error)
- func SHA256FromJSON[T interface{}](a T) (string, error)
- func SHA256FromString(data string) string
- func SHA256FromStringArray(data ...string) string
- func SHA256FromStringMap(data map[string]string) string
- func Sort[IN any](in []IN, cmp func(i, j IN) bool) []IN
- func SortKeys[V any](m map[string]V) []string
- func TimeAgencyLayouts() []string
- func TimeCompareEqual(a, b meta.Time) bool
- func TimeCompareEqualPointer(a, b *meta.Time) bool
- func TokenAuthInterceptors(token string) []grpc.DialOption
- func TypeOrDefault[T interface{}](input *T, defaultValue ...T) T
- func UniqueList[A comparable](in []A) []A
- func WithContextTimeoutP1A1[P1, A1 interface{}](ctx context.Context, timeout time.Duration, f func(context.Context, A1) P1, ...) P1
- func WithContextTimeoutP1A2[P1, A1, A2 interface{}](ctx context.Context, timeout time.Duration, f func(context.Context, A1, A2) P1, ...) P1
- func WithContextTimeoutP1A4[P1, A1, A2, A3, A4 interface{}](ctx context.Context, timeout time.Duration, ...) P1
- func WithContextTimeoutP2A2[P1, P2, A1, A2 interface{}](ctx context.Context, timeout time.Duration, ...) (P1, P2)
- func WithContextTimeoutP2A4[P1, P2, A1, A2, A3, A4 interface{}](ctx context.Context, timeout time.Duration, ...) (P1, P2)
- func WithContextTimeoutP4A3[P1, P2, P3, P4, A1, A2, A3 interface{}](ctx context.Context, timeout time.Duration, ...) (P1, P2, P3, P4)
- func WithDefault[T interface{}](in *T) T
- func WithKubernetesContextTimeoutP1A1[P1, A1 interface{}](ctx context.Context, f func(context.Context, A1) P1, a1 A1) P1
- func WithKubernetesContextTimeoutP1A2[P1, A1, A2 interface{}](ctx context.Context, f func(context.Context, A1, A2) P1, a1 A1, a2 A2) P1
- func WithKubernetesContextTimeoutP1A4[P1, A1, A2, A3, A4 interface{}](ctx context.Context, f func(context.Context, A1, A2, A3, A4) P1, a1 A1, a2 A2, ...) P1
- func WithKubernetesContextTimeoutP2A2[P1, P2, A1, A2 interface{}](ctx context.Context, f func(context.Context, A1, A2) (P1, P2), a1 A1, a2 A2) (P1, P2)
- func WithKubernetesContextTimeoutP2A4[P1, P2, A1, A2, A3, A4 interface{}](ctx context.Context, f func(context.Context, A1, A2, A3, A4) (P1, P2), a1 A1, ...) (P1, P2)
- func WithKubernetesContextTimeoutP4A3[P1, P2, P3, P4, A1, A2, A3 interface{}](ctx context.Context, f func(context.Context, A1, A2, A3) (P1, P2, P3, P4), ...) (P1, P2, P3, P4)
- func WithKubernetesPatch[P1 meta.Object](ctx context.Context, obj string, client PatchInterface[P1], p ...patch.Item) (P1, error)
- func WriteAll(out io.Writer, data []byte) (int, error)
- type ConditionalFunction
- type ConditionalP1Function
- type EnvironmentVariable
- type Hash
- type Interval
- type KV
- type List
- func (l List[T]) Append(items ...T) List[T]
- func (l List[T]) Contains(fn func(T) bool) bool
- func (l List[T]) Count(fn func(T) bool) int
- func (l List[T]) Filter(fn func(T) bool) List[T]
- func (l List[T]) List() []T
- func (l List[T]) Sort(fn func(T, T) bool) List[T]
- func (l List[T]) Unique(f func(existing List[T], a T) bool) List[T]
- type Loader
- type LoaderGen
- type Mod
- type PatchInterface
- type Registerer
Constants ¶
const AuthorizationGRPCHeader = "adb-authorization"
const TimeLayout = time.RFC3339
Variables ¶
This section is empty.
Functions ¶
func BoolSwitch ¶
func BoolSwitch[T interface{}](s bool, t, f T) T
BoolSwitch define bool switch for defined types - in case of true t T is returned, in case of false f T
func CheckConditionalNil ¶
func CheckConditionalNil[T interface{}](in ConditionalFunction[T]) *T
func CheckConditionalP1Nil ¶
func CheckConditionalP1Nil[T, P1 interface{}](in ConditionalP1Function[T, P1], p1 P1) *T
func CompareInt ¶
func CompareInt64 ¶
func CompareInt64p ¶
func CompareIntp ¶
func CompareJSON ¶
func CompareJSONP ¶
func ContainsList ¶
func ContainsList[A comparable](in []A, item A) bool
func CopyFullMap ¶
func CopyFullMap[K comparable, V any](src map[K]V) map[K]V
func CreateSignalContext ¶
CreateSignalContext creates and returns the context which is closed when one of the provided signal occurs. SIGINT and SIGTERM is used by default.
func DefaultInterface ¶
func DefaultInterface[T interface{}]() interface{}
DefaultInterface returns generic default value for type T as Interface
func FirstNotDefault ¶
func FirstNotDefault[T interface{}](input ...T) T
FirstNotDefault returns first not default value
func FlattenList ¶
func FlattenList[A any](in [][]A) []A
func FormatList ¶
func FormatList[A, B any](in []A, format func(A) B) []B
func FormatListErr ¶
func InitOptional ¶
func InitType ¶
func InitType[T interface{}](in *T) *T
InitType initialise object if it is nil pointer
func IterateSorted ¶
func JSONRemarshal ¶
func LastFromList ¶
func LastFromList[T interface{}](in []T) T
LastFromList returns last element on the list
func ListAsMap ¶
func ListAsMap[K comparable, V any](in []V, extract func(in V) K) map[K]V
func MD5FromString ¶
func MapKeys ¶
func MapKeys[K comparable, V any](m map[K]V) []K
func MapValues ¶
func MapValues[K comparable, V any](m map[K]V) []V
func MergeMaps ¶
func MergeMaps[K comparable, V any](override bool, maps ...map[K]V) map[K]V
func NewGRPCClient ¶
func NewGRPCConn ¶
func NewGRPCConn(addr string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
func NewOptionalTLSGRPCConn ¶
func NewOptionalTLSGRPCConn(ctx context.Context, addr string, tls *tls.Config, opts ...grpc.DialOption) (*grpc.ClientConn, error)
func NewType ¶
func NewType[T interface{}](input T) *T
NewType returns a reference to a simple type with given value.
func NewTypeOrNil ¶
func NewTypeOrNil[T interface{}](input *T) *T
NewTypeOrNil returns nil if input is nil, otherwise returns a clone of the given value.
func NormalizeEnv ¶
NormalizeEnv normalizes environment variables.
func Optional ¶
func Optional[K comparable, V any](m map[K]V, key K, def V) V
func OptionalType ¶
func OptionalType[T any](in *T, v T) T
OptionalType returns the default value (or T default value)
func ParallelThread ¶
func ParallelThread(max int) (chan struct{}, func())
func PickFromList ¶
func RandomElement ¶
func RandomElement[T interface{}](in []T) (T, bool)
func RunParallel ¶
RunParallel runs actions parallelly throttling them to the given maximum number.
func SHA256FromExtract ¶
func SHA256FromFile ¶
func SHA256FromHashArray ¶
func SHA256FromJSON ¶
func SHA256FromString ¶
func SHA256FromStringArray ¶
func SHA256FromStringMap ¶
func TimeAgencyLayouts ¶
func TimeAgencyLayouts() []string
func TimeCompareEqual ¶
TimeCompareEqual compares two times, allowing an error of 1s
func TimeCompareEqualPointer ¶
TimeCompareEqualPointer compares two times, allowing an error of 1s Returns true if both pointers are nil
func TokenAuthInterceptors ¶
func TokenAuthInterceptors(token string) []grpc.DialOption
func TypeOrDefault ¶
func TypeOrDefault[T interface{}](input *T, defaultValue ...T) T
TypeOrDefault returns the default value (or T default value) if input is nil, otherwise returns the referenced value.
func UniqueList ¶
func UniqueList[A comparable](in []A) []A
func WithContextTimeoutP1A1 ¶
func WithContextTimeoutP1A2 ¶
func WithContextTimeoutP1A4 ¶
func WithContextTimeoutP2A2 ¶
func WithContextTimeoutP2A4 ¶
func WithContextTimeoutP4A3 ¶
func WithDefault ¶
func WithDefault[T interface{}](in *T) T
WithDefault returns generic default value for type T if in is nil
func WithKubernetesPatch ¶
Types ¶
type ConditionalFunction ¶
type ConditionalFunction[T interface{}] func() (T, bool)
type ConditionalP1Function ¶
type ConditionalP1Function[T, P1 interface{}] func(p1 P1) (T, bool)
type EnvironmentVariable ¶
type EnvironmentVariable string
EnvironmentVariable is a wrapper to get environment variables
func (EnvironmentVariable) Exists ¶
func (e EnvironmentVariable) Exists() bool
Exists check if variable is defined
func (EnvironmentVariable) Get ¶
func (e EnvironmentVariable) Get() string
Get fetch variable. If variable does not exist empty string is returned
func (EnvironmentVariable) GetOrDefault ¶
func (e EnvironmentVariable) GetOrDefault(d string) string
GetOrDefault fetch variable. If variable is not defined default value is returned
func (EnvironmentVariable) Lookup ¶
func (e EnvironmentVariable) Lookup() (string, bool)
Lookup for environment variable
func (EnvironmentVariable) String ¶
func (e EnvironmentVariable) String() string
String return string representation of environment variable name
type Interval ¶
Interval is a specialization of Duration so we can add some helper functions to that.
func (Interval) After ¶
After waits for the interval to elapse and then sends the current time on the returned channel.
func (Interval) IncreaseTo ¶
IncreaseTo returns an interval that is equal to max(x, i).
type KV ¶
type KV[K comparable, V any] struct { K K V V }
func Extract ¶
func Extract[K comparable, V any](in map[K]V) []KV[K, V]
func ExtractWithSort ¶
func ExtractWithSort[K comparable, V any](in map[K]V, cmp func(i, j K) bool) []KV[K, V]
type List ¶
type List[T any] []T
func MapList ¶
func MapList[T, V comparable](in List[T], fn func(T) V) List[V]
type Loader ¶
func NewYamlLoader ¶
type PatchInterface ¶
type Registerer ¶
type Registerer[K comparable, V any] interface { Register(key K, value V) bool MustRegister(key K, value V) Items() []KV[K, V] }
func NewRegisterer ¶
func NewRegisterer[K comparable, V any]() Registerer[K, V]