collections

package
v0.6.288 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCanceled is the error returned when the context is canceled.
	ErrCanceled = context.Canceled
	// ErrTimeout is the error returned when the context's deadline passes.
	ErrTimeout = context.DeadlineExceeded
)
View Source
var DefaultConverters = CopierConverters{
	timeToPBTimeStamp,
	timePtrToPBTimeStamp,
	pbTimeStampToTime,
	pbTimeStampToTimePtr,
}

Functions

func Accumulate added in v0.6.124

func Accumulate[A any, T any](items []T, accumulator func(A, T) A) A

func AccumulateE added in v0.6.124

func AccumulateE[A any, T any](items []T, accumulator func(A, T) (A, error)) (A, error)

func AccumulateMap added in v0.6.288

func AccumulateMap[A any, K comparable, V any](m map[K]V, accumulator func(A, K, V) A) A

func Any

func Any[T any](f func(T) bool, list []T)

func C added in v0.6.53

func C[T any](fns ...func(some T) T) func(some T) T

func C2 added in v0.6.53

func C2[T any, S any, R any](fn1 func(some S) R, fn2 func(some T) S) func(some T) R

func C3 added in v0.6.53

func C3[T any, S any, R any, U any](fn0 func(some R) U, fn1 func(some S) R, fn2 func(some T) S) func(some T) U

func C4 added in v0.6.53

func C4[T any, S any, R any, U any, V any](fn01 func(some U) V, fn0 func(some R) U, fn1 func(some S) R, fn2 func(some T) S) func(some T) V

func C5 added in v0.6.53

func C5[T any, S any, R any, U any, V any, W any](fn02 func(some V) W, fn01 func(some U) V, fn0 func(some R) U, fn1 func(some S) R, fn2 func(some T) S) func(some T) W

func Chunk added in v0.6.288

func Chunk[T any](list []T, chunkSize int) [][]T

func CloneList added in v0.6.288

func CloneList[T any](l []T) []T

func CloneMap added in v0.6.288

func CloneMap[T any, K comparable](m map[K]T) map[K]T

func Compose added in v0.6.53

func Compose[T any, S any, R any](fn1 func(some S) R, fn2 func(some T) S) func(some T) R

func Concat

func Concat[T any](left []T, right []T) []T

func Cons added in v0.6.53

func Cons[X any](x X, list []X) []X

func Contains added in v0.6.74

func Contains[T comparable](s []T, e T) bool

func ContainsAny added in v0.6.288

func ContainsAny(s string, subs ...string) bool

func ContainsDuplicatesErr added in v0.6.124

func ContainsDuplicatesErr[T comparable](list []T) error

func ContextWithIdempotencyKey added in v0.6.288

func ContextWithIdempotencyKey(ctx context.Context, idempotencyKey string) context.Context

func CopyPtrVal added in v0.6.288

func CopyPtrVal[T any](t *T) (*T, error)

func CopyVal added in v0.6.288

func CopyVal[T any](t T) (T, error)

func DecodeBase64OrValue added in v0.6.288

func DecodeBase64OrValue(s string) (string, error)

func Deduplicate added in v0.6.288

func Deduplicate[T comparable](list []T) []T

func DeepEqual added in v0.6.288

func DeepEqual[T any](i T, l T) bool

func DefaultPtr added in v0.6.124

func DefaultPtr[T any](value *T, defaultValue T) T

func DefaultPtrOrValue added in v0.6.124

func DefaultPtrOrValue[T any](value *T, defaultValue T) T

return default if ptr is nil or de-referenced ptr value is empty

func DefaultValue added in v0.6.124

func DefaultValue[T any](value T, defaultValue T) T

func Deref added in v0.6.124

func Deref[T any](x *T) T

func DictMerge

func DictMerge[K comparable, V any](left map[K]V, right map[K]V) map[K]V

func Difference

func Difference[T comparable](from []T, remove []T) []T

func DistinctChan added in v0.6.288

func DistinctChan[T any, K comparable](
	keyGetter func(T any) K, bufSize int,
) (input chan T, output chan T)

func DoAfterE added in v0.6.288

func DoAfterE(ctx context.Context, d time.Duration,
	f func() error,
	done func(context.Context) error,
) error

func DoForever added in v0.6.288

func DoForever(ctx context.Context, f func())

cancel context to end

func DoForeverE added in v0.6.288

func DoForeverE(ctx context.Context,
	f func() error,
	done func(context.Context) error,
) error

func DoOnDuration added in v0.6.288

func DoOnDuration(ctx context.Context, d time.Duration, f func())

cancel context to end

func DoOnDurationE added in v0.6.288

func DoOnDurationE(ctx context.Context, d time.Duration,
	f func() error,
	done func(context.Context) error,
) error

end early if err

func DoWithTimeout added in v0.6.288

func DoWithTimeout(fn func(ctx context.Context) error, timeout time.Duration, opts ...TimeoutOptions) error

if you loop forever, make sure you have a way to break the loop see Test_DoWithTimeoutTimeoutLoop

func DoWithTimeoutData added in v0.6.288

func DoWithTimeoutData[T any](fn func(ctx context.Context) (T, error), timeout time.Duration, opts ...TimeoutOptions) (T, error)

if you loop forever, make sure you have a way to break the loop see Test_DoWithTimeoutTimeoutLoop

func Duplicate

func Duplicate[T any](x T) []T

func Enconcat added in v0.6.53

func Enconcat[X any](before []X, x X, after []X) []X

func Except added in v0.6.288

func Except[T comparable](items []T, except []T) []T

Await blocks until the asynchronous operation completes, returning the result and error.

func Fanout

func Fanout[T any, R any](fs []func(T) R, item T) []R

func Filter

func Filter[T any](list []T, f func(T) bool) []T

returns those that are true

func FilterE added in v0.6.288

func FilterE[T any](list []T, f func(T) (bool, error)) ([]T, error)

returns those that are true

func FilterEmpty added in v0.6.74

func FilterEmpty[T comparable](l []T) []T

func FilterOutEmpty added in v0.6.288

func FilterOutEmpty[T any](list []T) []T

func Find added in v0.6.124

func Find[T any](list []T, f func(T) bool) *T

func FindPtr added in v0.6.288

func FindPtr[T any](list []*T, f func(*T) bool) *T

func First added in v0.6.53

func First[X any](list []X) *X

func Flatmap

func Flatmap[T any, R any](fn func(some T) []R, list []T) []R

Take a list of things and a function that returns a list of things then combines list after mapping func T -> [R, R, R ...] [T, T, T ...] -> [R, R, R ...]

func FlatmapE added in v0.6.124

func FlatmapE[T any, R any](fn func(some T) ([]R, error), list []T) ([]R, error)

Take a list of things and a function that returns a list of things then combines list after mapping (return early from error) func T -> [R, R, R ...] [T, T, T ...] -> [R, R, R ...]

func Flatten added in v0.6.124

func Flatten[T any](listOfLists [][]T) []T

func Flip added in v0.6.53

func Flip[X any, Y any, Z any](fn func(X, Y) Z) func(Y, X) Z

func Fmap

func Fmap[T any, R any](fn func(some T) R, list []T) []R

func Foldl

func Foldl[T any, R any](fn func(acc R, next T) R, base R, list []T) R

func FoldlE added in v0.6.124

func FoldlE[T any, R any](fn func(acc R, next T) (R, error), base R, list []T) (R, error)

func Foldr

func Foldr[T any, R any](fn func(next T, carry R) R, base R, list []T) R

func FromJSON added in v0.6.124

func FromJSON[T any](j []byte) (T, error)

func GetAValueFromMap added in v0.6.124

func GetAValueFromMap[K comparable, V any](m map[K]V) *V

func GetFieldName added in v0.6.288

func GetFieldName(structPtr any, fieldPtr any) string

func GetFirstKeyThatContainsNoCase added in v0.6.288

func GetFirstKeyThatContainsNoCase[T any](m map[string]T, s string) string

func GetFunctionName added in v0.6.288

func GetFunctionName(i any) string

func GetIdempotencyKeyFromContext added in v0.6.288

func GetIdempotencyKeyFromContext(ctx context.Context) string

func GetMapKeys added in v0.6.124

func GetMapKeys[K comparable, V any](m map[K]V) []K

func GetMapValues added in v0.6.124

func GetMapValues[K comparable, V any](m map[K]V) []V

func GetRequestWithContext added in v0.6.270

func GetRequestWithContext(ctx context.Context, url string) (*http.Response, error)

getWithContext creates and sends an HTTP GET request with the provided context

func GroupBy added in v0.6.288

func GroupBy[K comparable, A any](list []A, keyGetter func(A) K) map[K][]A

func GroupByE added in v0.6.288

func GroupByE[T comparable, A any](list []A, f func(A) (T, error)) (map[T][]A, error)

func ID added in v0.6.270

func ID[T any](x T) T

func InitialNotEqual added in v0.6.124

func InitialNotEqual[T any](i T) func(l T) bool

func IsEmpty added in v0.6.124

func IsEmpty[T any](x T) bool

func IsEmptyValP added in v0.6.124

func IsEmptyValP[T any](x *T) bool

func Iterate added in v0.6.288

func Iterate[T any](hasNext func() bool, next func() (T, error), do func(a T) (bool, error)) error

func IterateToSlice added in v0.6.288

func IterateToSlice[T any](f func() (bool, T, error)) ([]T, error)

Assumes that if cont is false res is empty

func Keys added in v0.6.53

func Keys[T comparable, R any](dict map[T]R) []T

func LastXChars added in v0.6.288

func LastXChars(s string, x int) string

func ListAnyDiff added in v0.6.288

func ListAnyDiff[T any, C comparable](a []T, b []T, toComp func(t T) C) []T

func ListContains added in v0.6.124

func ListContains[K comparable](list []K, item K) bool

func ListDiff added in v0.6.288

func ListDiff[T comparable](a []T, b []T) []T

func ListHas added in v0.6.124

func ListHas[K any](list []K, has func(l K) bool) bool

loops over list and returns when has returns true

func ListItemsAreErr added in v0.6.124

func ListItemsAreErr[T comparable](items []T, are []T) error

takes a list of items and checks if items are elements in another list

func ListOfPointersToListOfValues added in v0.6.124

func ListOfPointersToListOfValues[T any](list []*T) []T

func ListOfSomethingToListOfAny added in v0.6.124

func ListOfSomethingToListOfAny[T any](l []T) []any

func ListToChannel added in v0.6.288

func ListToChannel[T any](l []T) chan T

func ListToCollisionMap added in v0.6.288

func ListToCollisionMap[T comparable](list []T) map[T]bool

func ListToMap added in v0.6.288

func ListToMap[T any, R comparable](list []T, keySelector func(l T) R) map[R]T

func ListToMapE added in v0.6.288

func ListToMapE[T any, R comparable](list []T, keySelector func(l T) (R, error)) (map[R]T, error)

func ListToMapKV added in v0.6.288

func ListToMapKV[T any, R comparable, V any](list []T, keySelector func(l T) R, valueSelector func(l T) V) map[R]V

func MakePrefixIdempotencyKeyFromCtx added in v0.6.288

func MakePrefixIdempotencyKeyFromCtx(ctx context.Context, prefix string) string

func ManyIntegersToInts added in v0.6.124

func ManyIntegersToInts[T constraints.Integer](i []T) []int

func ManyStringLikeToStrings added in v0.6.124

func ManyStringLikeToStrings[T ~string](i []T) []string

func Map added in v0.6.124

func Map[T, R any](items []T, mapper func(T) R) []R

func T -> R [T, T, T ...] -> [R, R, R ...]

func MapContainsKey added in v0.6.111

func MapContainsKey[K comparable, V any](m map[K]V, key K) bool

func MapDiff added in v0.6.288

func MapDiff[K comparable, V1 any, V2 any](a map[K]V1, b map[K]V2) map[K]V1

creates a map of the keys in a and not in b

func MapE added in v0.6.124

func MapE[T, R any](items []T, mapper func(T) (R, error)) ([]R, error)

func MapFromList added in v0.6.124

func MapFromList[T any, R comparable](list []T, keySelector func(l T) R) map[R]T

func MapHasKey added in v0.6.288

func MapHasKey[K comparable, V any](m map[K]V, key K) bool

func MapMap added in v0.6.288

func MapMap[K comparable, V any, R any](m map[K]V, f func(K, V) R) []R

map over a go map

func MapMapE added in v0.6.288

func MapMapE[K comparable, V any, R any](m map[K]V, f func(K, V) (R, error)) ([]R, error)

func MapMapMerge added in v0.6.288

func MapMapMerge[K1 comparable, V1 any, K2 comparable, V2 any](m map[K1]V1, f func(K1, V1) map[K2]V2) map[K2]V2

map over a go map and return a map, merge the maps

func MapToGenericMap added in v0.6.288

func MapToGenericMap[v any](m map[string]v) map[string]interface{}

func MapToStruct added in v0.6.124

func MapToStruct[T any](m any) (T, error)

pass in m a map of string to any

func Max added in v0.6.288

func Max[T constraints.Ordered](x T, y T) T

func MergeMaps added in v0.6.124

func MergeMaps[K comparable, V any](maps ...map[K]V) map[K]V

right maps override left if they have the same key

func Min added in v0.6.288

func Min[T constraints.Ordered](x T, y T) T

func MultiGroupBy added in v0.6.288

func MultiGroupBy[T comparable, A any](list []A, f func(A) []T) map[T][]A

func OnTick added in v0.6.288

func OnTick(ctx context.Context, d time.Duration, f func()) *time.Ticker

func P2 added in v0.6.53

func P2[X any, Y any, Z any](fn func(X, Y) Z, x X) func(Y) Z

func ParallelMapE added in v0.6.288

func ParallelMapE[T, R any](items []T, mapper func(T) (R, error)) ([]R, error)

func ParallelWorkerMapE added in v0.6.288

func ParallelWorkerMapE[T, R any](items []T, mapper func(T) (R, error), maxWorkers int) ([]R, error)

func ParallelWorkerMapExitOnE added in v0.6.288

func ParallelWorkerMapExitOnE[T, R any](ctx context.Context, items []T, mapper func(context.Context, T) (R, error), maxWorkers int) ([]R, error)

Early returns if one error is found, will return partial work

func ProtoToFormattedString added in v0.6.288

func ProtoToFormattedString(m proto.Message) string

for testing, and printing to screen, ignores error

func Ptr added in v0.6.124

func Ptr[T any](x T) *T

func RemoveDuplicates added in v0.6.124

func RemoveDuplicates[T comparable](list []T) []T

func RetryTest added in v0.6.288

func RetryTest(t *testing.T, testFunc func(t *testing.T), numRetries int)

func RetryWithAttemptCount added in v0.6.288

func RetryWithAttemptCount(o backoff.Operation, b backoff.BackOff) error

func RetryWithDataAndAttemptCount added in v0.6.288

func RetryWithDataAndAttemptCount[T any](o backoff.OperationWithData[T], b backoff.BackOff) (T, error)

func ReturnOnCondition added in v0.6.124

func ReturnOnCondition[T any](ctx context.Context, fetcher func(ctx context.Context) (T, error), conditional func(i T) bool, updateDuration time.Duration) (T, error)

func ReverseList added in v0.6.288

func ReverseList[T any](list []T)

func RoundToNearestBase added in v0.6.288

func RoundToNearestBase(num float64, base float64) float64

func RoundToNearestDecimal added in v0.6.288

func RoundToNearestDecimal(num float64, decimalPlaces int) float64

func Run added in v0.6.288

func Run[T any](l []T, f func(t T))

func RunAllWithShutdown added in v0.6.288

func RunAllWithShutdown(ctx context.Context, runners []Runnable, shutdownChan <-chan any) error

RunAllWithShutdown runs Runnabls in parallel and waits for shutdown signal (max n seconds) if one runner errors or panics

func S added in v0.6.53

func S[T any](fns ...func(some T) T) func(some T) T

func SleepWithHealthCheck added in v0.6.288

func SleepWithHealthCheck(d time.Duration, tickRate time.Duration, heartbeatFn func())

SleepWithHealthCheck sleeps for the specified duration `d` and periodically calls `heartbeatFn` at every `tickRate` until `d` has elapsed.

func SortBy added in v0.6.53

func SortBy[T any](sortFn func(T, T) bool, list []T) []T

sortFn if i < j then ascending (1,2,3), if i > j then descending (3,2,1)

func SortByE added in v0.6.288

func SortByE[T any](sortFn func(T, T) (bool, error), list []T) ([]T, error)

sortFn if i < j then ascending (1,2,3), if i > j then descending (3,2,1)

func SortEachBucket added in v0.6.288

func SortEachBucket[T comparable, A any](bucketedMap map[T][]A, f func(a A, b A) bool) map[T][]A

func ToDict

func ToDict[T comparable](xs []T) map[T]bool

func ToJSONString added in v0.6.288

func ToJSONString(i any) string

returns json string or empty if fails

func TryCopyTo added in v0.6.124

func TryCopyTo[T any, R any](t T, r R) (R, error)

func TryCopyToNew added in v0.6.124

func TryCopyToNew[T any, R any](t T, options ...CopyOption) (R, error)

func TryCopyToNewE added in v0.6.288

func TryCopyToNewE[T any, R any](t T, mappers ...CopyMappingFunc[T, R]) (R, error)

For testing different DX

func TryCopyToNewOptions added in v0.6.288

func TryCopyToNewOptions[T any, R any](t T, options CopyOptions) (R, error)

func TryCopyToOptions added in v0.6.288

func TryCopyToOptions[T any, R any](t T, r R, options CopyOptions) (R, error)

func Uniq

func Uniq[T comparable](xs []T) []T

func ValueOrZero added in v0.6.124

func ValueOrZero[T any](ptr *T) T

func ZeroValueToNil added in v0.6.124

func ZeroValueToNil[T any](x T) *T

return value or nil if value is zero

Types

type AsyncResult added in v0.6.280

type AsyncResult[T any] struct {
	// contains filtered or unexported fields
}

func Async added in v0.6.280

func Async[T any](f func() (T, error)) *AsyncResult[T]

func (*AsyncResult[T]) Await added in v0.6.280

func (ar *AsyncResult[T]) Await() (T, error)

Await blocks until the asynchronous operation completes, returning the result and error.

type BufferedObjects added in v0.6.288

type BufferedObjects[T any] struct {
	// contains filtered or unexported fields
}

func NewBufferedObjects added in v0.6.288

func NewBufferedObjects[T any](flushSize int, flushInterval time.Duration, flushHandler func([]T)) *BufferedObjects[T]

func (*BufferedObjects[T]) Add added in v0.6.288

func (bi *BufferedObjects[T]) Add(object T)

func (*BufferedObjects[T]) Flush added in v0.6.288

func (bi *BufferedObjects[T]) Flush()

func (*BufferedObjects[T]) SetBufferSize added in v0.6.288

func (bi *BufferedObjects[T]) SetBufferSize(flushSize int)

func (*BufferedObjects[T]) Stop added in v0.6.288

func (bi *BufferedObjects[T]) Stop()

func (*BufferedObjects[T]) WaitTillEmpty added in v0.6.288

func (bi *BufferedObjects[T]) WaitTillEmpty()

type ContextKey added in v0.6.288

type ContextKey string
const IdempotencyKeyName ContextKey = "idempotencyKey"

type CopierConverter added in v0.6.288

type CopierConverter interface {
	ToCopierTypeConverter() copier.TypeConverter
}

type CopierConverters added in v0.6.288

type CopierConverters []CopierConverter

func (CopierConverters) ToCopierTypeConverters added in v0.6.288

func (c CopierConverters) ToCopierTypeConverters() []copier.TypeConverter

type CopyConverter added in v0.6.288

type CopyConverter[T, R any] func(T) (R, error)

func (CopyConverter[T, R]) ToCopierTypeConverter added in v0.6.288

func (c CopyConverter[T, R]) ToCopierTypeConverter() copier.TypeConverter

type CopyMap added in v0.6.288

type CopyMap map[string]string

type CopyMapper added in v0.6.288

type CopyMapper interface {
	ToCopierMapping() copier.FieldNameMapping
}

type CopyMappers added in v0.6.288

type CopyMappers []CopyMapper

func (CopyMappers) ToCopierMappings added in v0.6.288

func (c CopyMappers) ToCopierMappings() []copier.FieldNameMapping

type CopyMapping added in v0.6.288

type CopyMapping[T, R any] map[string]string

func (CopyMapping[T, R]) ToCopierMapping added in v0.6.288

func (c CopyMapping[T, R]) ToCopierMapping() copier.FieldNameMapping

type CopyMappingFunc added in v0.6.288

type CopyMappingFunc[T, R any] func(T, R) map[any]any

func (CopyMappingFunc[T, R]) ToCopierMapping added in v0.6.288

func (c CopyMappingFunc[T, R]) ToCopierMapping() copier.FieldNameMapping

Doesn't work but leaving for future reference

type CopyOption added in v0.6.288

type CopyOption interface {
	// contains filtered or unexported methods
}

type CopyOptions added in v0.6.288

type CopyOptions struct {
	ShallowCopy           bool
	OmitDefaultConverters bool
	Converters            CopierConverters
	Mappers               CopyMappers // create mappings for any arbitrary type
}

func (CopyOptions) ToCopierOptions added in v0.6.288

func (c CopyOptions) ToCopierOptions() copier.Option

type DoOption added in v0.6.288

type DoOption func() context.Context

DoOption defines the method to customize a DoWithTimeout call.

func WithContext added in v0.6.288

func WithContext(ctx context.Context) DoOption

WithContext customizes a DoWithTimeout call with given ctx.

type DumbCopyMapper added in v0.6.288

type DumbCopyMapper struct {
	Mapping copier.FieldNameMapping
}

func (DumbCopyMapper) ToCopierMapping added in v0.6.288

func (d DumbCopyMapper) ToCopierMapping() copier.FieldNameMapping

type MapKeyVal added in v0.6.288

type MapKeyVal[K comparable, V any] struct {
	Key   K
	Value V
}

func MapToList added in v0.6.288

func MapToList[K comparable, T any](m map[K]T) []MapKeyVal[K, T]

type Params added in v0.6.124

type Params[T any] struct {
	Value T
	Ctx   context.Context
}

type Result added in v0.6.124

type Result[T any] struct {
	Value T
	Err   error
}

func (Result[T]) Unwrap added in v0.6.124

func (r Result[T]) Unwrap() (T, error)

type Rollback added in v0.6.288

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

func NewRollback added in v0.6.288

func NewRollback(undo func() error) *Rollback

func (*Rollback) Add added in v0.6.288

func (r *Rollback) Add(undo func() error)

func (Rollback) Rollback added in v0.6.288

func (r Rollback) Rollback() error

type Runnable added in v0.6.288

type Runnable interface {
	Run(ctx context.Context) error
	Shutdown(ctx context.Context) error
}

type SafeCounter added in v0.6.288

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

func NewSafeCounter added in v0.6.288

func NewSafeCounter() *SafeCounter

func (*SafeCounter) Dec added in v0.6.288

func (c *SafeCounter) Dec()

func (*SafeCounter) Get added in v0.6.288

func (c *SafeCounter) Get() int

func (*SafeCounter) Inc added in v0.6.288

func (c *SafeCounter) Inc()

type SafeMap added in v0.6.288

type SafeMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

SafeMap is a generic map guarded by a RW mutex.

func NewSafeMap added in v0.6.288

func NewSafeMap[K comparable, V any]() *SafeMap[K, V]

NewSafeMap creates a new SafeMap.

func (*SafeMap[K, V]) Clear added in v0.6.288

func (m *SafeMap[K, V]) Clear()

Clear removes all entries from the map.

func (*SafeMap[K, V]) Copy added in v0.6.288

func (m *SafeMap[K, V]) Copy() *SafeMap[K, V]

Copy creates a new SafeMap with the same key-value pairs.

func (*SafeMap[K, V]) CopyMap added in v0.6.288

func (m *SafeMap[K, V]) CopyMap(c *SafeMap[K, V]) *SafeMap[K, V]

Sets the pointer of the current map to a copy of the map passed in.

func (*SafeMap[K, V]) Delete added in v0.6.288

func (m *SafeMap[K, V]) Delete(key K)

Delete removes a key from the map.

func (*SafeMap[K, V]) Get added in v0.6.288

func (m *SafeMap[K, V]) Get(key K) (V, bool)

Get retrieves a value from the map.

func (*SafeMap[K, V]) Keys added in v0.6.288

func (m *SafeMap[K, V]) Keys() []K

func (*SafeMap[K, V]) Len added in v0.6.288

func (m *SafeMap[K, V]) Len() int

func (*SafeMap[K, V]) Override added in v0.6.288

func (m *SafeMap[K, V]) Override(s map[K]V)

func (*SafeMap[K, V]) Set added in v0.6.288

func (m *SafeMap[K, V]) Set(key K, value V)

Set sets a value in the map.

func (*SafeMap[K, V]) Values added in v0.6.288

func (m *SafeMap[K, V]) Values() []V

type SafeSet added in v0.6.288

type SafeSet[K comparable] struct {
	// contains filtered or unexported fields
}

func NewSafeSet added in v0.6.288

func NewSafeSet[K comparable]() *SafeSet[K]

func SliceToSafeSet added in v0.6.288

func SliceToSafeSet[T comparable](s []T) *SafeSet[T]

func (*SafeSet[K]) Add added in v0.6.288

func (s *SafeSet[K]) Add(key K)

func (*SafeSet[K]) Clear added in v0.6.288

func (s *SafeSet[K]) Clear()

func (*SafeSet[K]) Contains added in v0.6.288

func (s *SafeSet[K]) Contains(key K) bool

func (*SafeSet[K]) Len added in v0.6.288

func (s *SafeSet[K]) Len() int

func (*SafeSet[K]) Remove added in v0.6.288

func (s *SafeSet[K]) Remove(key K)

func (*SafeSet[K]) Values added in v0.6.288

func (s *SafeSet[K]) Values() []K

type SafeSlice added in v0.6.288

type SafeSlice[T any] struct {
	// contains filtered or unexported fields
}

func NewSafeSlice added in v0.6.288

func NewSafeSlice[T any]() *SafeSlice[T]

func (*SafeSlice[T]) Append added in v0.6.288

func (s *SafeSlice[T]) Append(value ...T)

Append adds a new element to the slice.

func (*SafeSlice[T]) Delete added in v0.6.288

func (s *SafeSlice[T]) Delete(index int) bool

func (*SafeSlice[T]) Get added in v0.6.288

func (s *SafeSlice[T]) Get(index int) (T, bool)

Get retrieves an element at a specific index.

func (*SafeSlice[T]) Set added in v0.6.288

func (s *SafeSlice[T]) Set(slice []T)

func (*SafeSlice[T]) SetAt added in v0.6.288

func (s *SafeSlice[T]) SetAt(index int, value T) bool

func (*SafeSlice[T]) Slice added in v0.6.288

func (s *SafeSlice[T]) Slice() []T

type SafeValue added in v0.6.288

type SafeValue[T any] struct {
	// contains filtered or unexported fields
}

SafeValue holds an arbitrary value with read and write protection. T is the type of the value.

func NewSafeValue added in v0.6.288

func NewSafeValue[T any](initialValue T) *SafeValue[T]

NewSafeValue creates a new SafeValue.

func (*SafeValue[T]) Get added in v0.6.288

func (sv *SafeValue[T]) Get() T

Get returns the value safely.

func (*SafeValue[T]) Set added in v0.6.288

func (sv *SafeValue[T]) Set(newValue T)

Set updates the value safely.

type TimeoutOptions added in v0.6.288

type TimeoutOptions struct {
	ParentContext context.Context
	CatchPanic    bool
}

type UniqueBufferedObjects added in v0.6.288

type UniqueBufferedObjects[T any] struct {
	// contains filtered or unexported fields
}

func NewUniqueBufferedObjects added in v0.6.288

func NewUniqueBufferedObjects[T any](
	flushSize int,
	flushInterval time.Duration,
	getID func(T) string,
	flushHandler func([]T),
) *UniqueBufferedObjects[T]

func (*UniqueBufferedObjects[T]) Add added in v0.6.288

func (bi *UniqueBufferedObjects[T]) Add(object T)

func (*UniqueBufferedObjects[T]) Flush added in v0.6.288

func (bi *UniqueBufferedObjects[T]) Flush()

func (*UniqueBufferedObjects[T]) Stop added in v0.6.288

func (bi *UniqueBufferedObjects[T]) Stop()

func (*UniqueBufferedObjects[T]) WaitTillEmpty added in v0.6.288

func (bi *UniqueBufferedObjects[T]) WaitTillEmpty()

Jump to

Keyboard shortcuts

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