util

package
v0.0.0-...-7c8ae26 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Concat

func Concat[A any](lists ...[]A) []A

func CopyByJson

func CopyByJson(source, dest any) error

func Every

func Every[A any](in []A, fn func(val A, index int) bool) bool

func Exists

func Exists[A any](in []A, fn func(val A, index int) bool) bool

func Filter

func Filter[A any](in []A, fn func(val A, index int) bool) []A

func Flatten

func Flatten[A any](in [][]A) []A

func GroupBy

func GroupBy[A any, B comparable](in []A, fn func(val A, index int) B) map[B][]A

func Includes

func Includes[A any](in []A, val A) bool

func Keys

func Keys[A comparable, B any](in map[A]B) []A

func Map

func Map[A, B any](in []A, fn func(val A, index int) B) []B

func MapOrError

func MapOrError[A, B any](in []A, fn func(A, int) (B, error)) (out []B, err error)

func NewRetryer

func NewRetryer() aws.Retryer

func OversizePartition

func OversizePartition[A any](list []A, size int, goOverSize func(previous, current A) bool) [][]A

func Partition

func Partition[A any](list []A, size int) [][]A

func Permutations

func Permutations[T any](vals []T) [][]T

Permutations generates all permutations of the input slice of any type.

func Range

func Range(begin, end, increment int) []int

func Reduce

func Reduce[A, B any](in []A, fn func(result B, current A, index int) B, initial B) (r B)

func Reverse

func Reverse[A any](in []A) []A

func Some

func Some[A any](in []A, fn func(val A, index int) bool) bool

func ToLambdaDynamoDB

func ToLambdaDynamoDB(attributes map[string]types.AttributeValue) map[string]events.DynamoDBAttributeValue

func ToSDKDynamoDB

func ToSDKDynamoDB(attributes map[string]events.DynamoDBAttributeValue) map[string]types.AttributeValue

func ToV2AttributeValueMap

func ToV2AttributeValueMap(m map[string]*dynamodbv1.AttributeValue) (map[string]types.AttributeValue, error)

func Unique

func Unique[A comparable](l []A) []A

func UniqueBy

func UniqueBy[A, B comparable](l []A, by func(A, int) B) []A

func Values

func Values[A comparable, B any](in map[A]B) []B

Types

type Entry

type Entry[A comparable, B any] struct {
	Key   A `json:"key"`
	Value B `json:"value"`
}

func Entries

func Entries[A comparable, B any](in map[A]B) []Entry[A, B]

type LocalResolver

type LocalResolver struct {
	URL string
}

func (*LocalResolver) ResolveEndpoint

func (r *LocalResolver) ResolveEndpoint(service, region string) (aws.Endpoint, error)

type NoOpRateLimit

type NoOpRateLimit struct{}

func (NoOpRateLimit) AddTokens

func (NoOpRateLimit) AddTokens(uint) error

func (NoOpRateLimit) GetToken

func (NoOpRateLimit) GetToken(context.Context, uint) (func() error, error)

type Retryer

type Retryer struct {
	// contains filtered or unexported fields
}

func (*Retryer) GetInitialToken

func (r *Retryer) GetInitialToken() (releaseToken func(error) error)

func (*Retryer) GetRetryToken

func (r *Retryer) GetRetryToken(ctx context.Context, opErr error) (releaseToken func(error) error, err error)

func (*Retryer) IsErrorRetryable

func (r *Retryer) IsErrorRetryable(err error) bool

func (*Retryer) MaxAttempts

func (r *Retryer) MaxAttempts() int

func (*Retryer) RetryDelay

func (r *Retryer) RetryDelay(attempt int, opErr error) (time.Duration, error)

Jump to

Keyboard shortcuts

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