Documentation ¶
Overview ¶
Package miscutil provides an "Island of Misfit Toys", but for helper functions
Index ¶
- func CacheFunc[K comparable, V any](f func(K) V, size int) func(K) V
- func Max[T constraints.Ordered](a, b T) T
- func Min[T constraints.Ordered](a, b T) T
- func ReadInto(dst []byte, r io.Reader) (int, error)
- func WithPipe(wcb func(w io.Writer) error, rcb func(r io.Reader) error) error
- type Iterator
- type WorkDeduper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheFunc ¶
func CacheFunc[K comparable, V any](f func(K) V, size int) func(K) V
CacheFunc caches any function with a single input and output. Uses a LRU with the given size. The size defualts to 100 to avoid errors.
Types ¶
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator provides functionality for generic imperative iteration. TODO: Move file set merge and datum merge to this abstraction. TODO: Improve when we upgrade to a go version with generics.
func NewIterator ¶
NewIterator creates a new iterator. DEPRECATED: use stream.NewFromForEach instead
type WorkDeduper ¶
type WorkDeduper[K comparable] struct { // contains filtered or unexported fields }
func (*WorkDeduper[K]) Do ¶
func (wd *WorkDeduper[K]) Do(ctx context.Context, k K, cb func() error) error
Concurrent calls to Do will block until cb has been completed by one of them, then the others will run, possibly concurrently. The motivating use case is to eliminate network round trips when populating a cache. Callers should check and populate the cache inside cb.