Documentation
¶
Index ¶
- Variables
- func ObjectMerge[T1 any, T2 any](base T1, override T2) T1
- func StructHash(dat any, opt ...StructHashOptions) (r []byte, err error)
- type BroadcastSubscription
- type Broadcaster
- func (bb *Broadcaster[TData]) Publish(data TData) (subscriber int, actualReceiver int)
- func (bb *Broadcaster[TData]) PublishWithContext(ctx context.Context, data TData) (subscriber int, actualReceiver int, err error)
- func (bb *Broadcaster[TData]) PublishWithTimeout(data TData, timeout time.Duration) (subscriber int, actualReceiver int)
- func (bb *Broadcaster[TData]) SubscribeByCallback(fn func(TData)) BroadcastSubscription
- func (bb *Broadcaster[TData]) SubscribeByChan(chanBufferSize int) (chan TData, BroadcastSubscription)
- func (bb *Broadcaster[TData]) SubscribeByIter(chanBufferSize int) (iter.Seq[TData], BroadcastSubscription)
- func (bb *Broadcaster[TData]) SubscriberCount() int
- type BufferedReadCloser
- type CASMutex
- func (m *CASMutex) Lock()
- func (m *CASMutex) RLock()
- func (m *CASMutex) RLocker() sync.Locker
- func (m *CASMutex) RTryLock() bool
- func (m *CASMutex) RTryLockWithContext(ctx context.Context) bool
- func (m *CASMutex) RTryLockWithTimeout(duration time.Duration) bool
- func (m *CASMutex) RUnlock()
- func (m *CASMutex) TryLock() bool
- func (m *CASMutex) TryLockWithContext(ctx context.Context) bool
- func (m *CASMutex) TryLockWithTimeout(duration time.Duration) bool
- func (m *CASMutex) Unlock()
- type DelayedCombiningInvoker
- func (d *DelayedCombiningInvoker) CancelPendingRequests()
- func (d *DelayedCombiningInvoker) CountPendingRequests() int
- func (d *DelayedCombiningInvoker) ExecuteNow() bool
- func (d *DelayedCombiningInvoker) HasPendingRequests() bool
- func (d *DelayedCombiningInvoker) RegisterOnExecutionDone(fn func())
- func (d *DelayedCombiningInvoker) RegisterOnExecutionStart(fn func(immediately bool))
- func (d *DelayedCombiningInvoker) RegisterOnRequest(fn func(pending int, initial bool))
- func (d *DelayedCombiningInvoker) Request()
- func (d *DelayedCombiningInvoker) WaitForCompletion(ctx context.Context) error
- type JsonOpt
- func (m JsonOpt[T]) IfSet(fn func(v T)) bool
- func (m JsonOpt[T]) IsSet() bool
- func (m JsonOpt[T]) IsUnset() bool
- func (m JsonOpt[T]) MarshalJSON() ([]byte, error)
- func (m JsonOpt[T]) MustValue() T
- func (m *JsonOpt[T]) UnmarshalJSON(data []byte) error
- func (m JsonOpt[T]) Value() (T, bool)
- func (m JsonOpt[T]) ValueDblPtrOrNil() **T
- func (m JsonOpt[T]) ValueOrNil() *T
- type LRUMap
- type MultiMutex
- func (mm *MultiMutex[TKey]) Get(key TKey) sync.Locker
- func (mm *MultiMutex[TKey]) GetCAS(key TKey) *CASMutex
- func (mm *MultiMutex[TKey]) Lock(key TKey)
- func (mm *MultiMutex[TKey]) RLock(key TKey)
- func (mm *MultiMutex[TKey]) RLocker(key TKey) sync.Locker
- func (mm *MultiMutex[TKey]) RTryLock(key TKey) bool
- func (mm *MultiMutex[TKey]) RTryLockWithContext(ctx context.Context, key TKey) bool
- func (mm *MultiMutex[TKey]) RTryLockWithTimeout(duration time.Duration, key TKey) bool
- func (mm *MultiMutex[TKey]) RUnlock(key TKey)
- func (mm *MultiMutex[TKey]) TryLock(key TKey) bool
- func (mm *MultiMutex[TKey]) TryLockWithContext(ctx context.Context, key TKey) bool
- func (mm *MultiMutex[TKey]) TryLockWithTimeout(key TKey, duration time.Duration) bool
- func (mm *MultiMutex[TKey]) Unlock(key TKey)
- type MutexSet
- type Nonuple
- func NewNonuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any, T9 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6, v7 T7, v8 T8, v9 T9) Nonuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]
- func NewTuple9[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any, T9 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6, v7 T7, v8 T8, v9 T9) Nonuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]
- type Octuple
- func NewOctuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6, v7 T7, v8 T8) Octuple[T1, T2, T3, T4, T5, T6, T7, T8]
- func NewTuple8[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6, v7 T7, v8 T8) Octuple[T1, T2, T3, T4, T5, T6, T7, T8]
- type PubSub
- func (ps *PubSub[TNamespace, TData]) Namespaces() []TNamespace
- func (ps *PubSub[TNamespace, TData]) Publish(ns TNamespace, data TData) (subscriber int, actualReceiver int)
- func (ps *PubSub[TNamespace, TData]) PublishWithContext(ctx context.Context, ns TNamespace, data TData) (subscriber int, actualReceiver int, err error)
- func (ps *PubSub[TNamespace, TData]) PublishWithTimeout(ns TNamespace, data TData, timeout time.Duration) (subscriber int, actualReceiver int)
- func (ps *PubSub[TNamespace, TData]) SubscribeByCallback(ns TNamespace, fn func(TData)) PubSubSubscription
- func (ps *PubSub[TNamespace, TData]) SubscribeByChan(ns TNamespace, chanBufferSize int) (chan TData, PubSubSubscription)
- func (ps *PubSub[TNamespace, TData]) SubscribeByIter(ns TNamespace, chanBufferSize int) (iter.Seq[TData], PubSubSubscription)
- func (ps *PubSub[TNamespace, TData]) SubscriberCount(ns TNamespace) int
- type PubSubSubscription
- type Quadruple
- type Quintuple
- type RingBuffer
- func (rb *RingBuffer[T]) At(i int) T
- func (rb *RingBuffer[T]) Capacity() int
- func (rb *RingBuffer[T]) Clear()
- func (rb *RingBuffer[T]) Get(i int) (T, bool)
- func (rb *RingBuffer[T]) IsFull() bool
- func (rb *RingBuffer[T]) Items() []T
- func (rb *RingBuffer[T]) Iter() iter.Seq[T]
- func (rb *RingBuffer[T]) Iter2() iter.Seq2[int, T]
- func (rb *RingBuffer[T]) Peek() (T, bool)
- func (rb *RingBuffer[T]) Push(item T)
- func (rb *RingBuffer[T]) PushPop(item T) *T
- func (rb *RingBuffer[T]) Remove(fnEqual func(v T) bool) int
- func (rb *RingBuffer[T]) Size() int
- type Septuple
- func NewSeptuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6, v7 T7) Septuple[T1, T2, T3, T4, T5, T6, T7]
- func NewTuple7[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any](v1 T1, v2 T2, v3 T3, v4 T4, v5 T5, v6 T6, v7 T7) Septuple[T1, T2, T3, T4, T5, T6, T7]
- type Sextuple
- type Single
- type Stack
- type StructHashOptions
- type SyncMap
- func (s *SyncMap[TKey, TData]) Clear()
- func (s *SyncMap[TKey, TData]) Contains(key TKey) bool
- func (s *SyncMap[TKey, TData]) Count() int
- func (s *SyncMap[TKey, TData]) Delete(key TKey) bool
- func (s *SyncMap[TKey, TData]) DeleteIf(fn func(key TKey, data TData) bool) int
- func (s *SyncMap[TKey, TData]) Get(key TKey) (TData, bool)
- func (s *SyncMap[TKey, TData]) GetAllKeys() []TKey
- func (s *SyncMap[TKey, TData]) GetAllValues() []TData
- func (s *SyncMap[TKey, TData]) GetAndSetIfNotContains(key TKey, data TData) TData
- func (s *SyncMap[TKey, TData]) GetAndSetIfNotContainsFunc(key TKey, data func() TData) TData
- func (s *SyncMap[TKey, TData]) Set(key TKey, data TData)
- func (s *SyncMap[TKey, TData]) SetIfNotContains(key TKey, data TData) bool
- func (s *SyncMap[TKey, TData]) SetIfNotContainsFunc(key TKey, data func() TData) bool
- func (s *SyncMap[TKey, TData]) UpdateIfExists(key TKey, fn func(data TData) TData) bool
- func (s *SyncMap[TKey, TData]) UpdateOrInsert(key TKey, fn func(data TData) TData, insertValue TData) bool
- type SyncRingSet
- func (s *SyncRingSet[TData]) Add(value TData) bool
- func (s *SyncRingSet[TData]) AddAll(values []TData)
- func (s *SyncRingSet[TData]) AddIfNotContains(key TData) bool
- func (s *SyncRingSet[TData]) Contains(value TData) bool
- func (s *SyncRingSet[TData]) Get() []TData
- func (s *SyncRingSet[TData]) Remove(value TData) bool
- func (s *SyncRingSet[TData]) RemoveAll(values []TData)
- func (s *SyncRingSet[TData]) RemoveIfContains(key TData) bool
- type SyncSet
- func (s *SyncSet[TData]) Add(value TData) bool
- func (s *SyncSet[TData]) AddAll(values []TData)
- func (s *SyncSet[TData]) AddIfNotContains(key TData) bool
- func (s *SyncSet[TData]) Contains(value TData) bool
- func (s *SyncSet[TData]) Get() []TData
- func (s *SyncSet[TData]) Remove(value TData) bool
- func (s *SyncSet[TData]) RemoveAll(values []TData)
- func (s *SyncSet[TData]) RemoveIfContains(key TData) bool
- type Triple
- type Tuple
- type ValueGroup
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyStack = errors.New("stack is empty")
Functions ¶
func ObjectMerge ¶
func StructHash ¶
func StructHash(dat any, opt ...StructHashOptions) (r []byte, err error)
Types ¶
type BroadcastSubscription ¶ added in v0.0.599
type BroadcastSubscription interface {
Unsubscribe()
}
type Broadcaster ¶ added in v0.0.599
type Broadcaster[TData any] struct { // contains filtered or unexported fields }
Broadcaster is a simple Broadcaster channel This is a simpler interface over Broadcaster - which does not have distinct namespaces
func NewBroadcaster ¶ added in v0.0.600
func NewBroadcaster[TData any](capacity int) *Broadcaster[TData]
func (*Broadcaster[TData]) Publish ¶ added in v0.0.599
func (bb *Broadcaster[TData]) Publish(data TData) (subscriber int, actualReceiver int)
Publish sends `data` to all subscriber But unbuffered - if one is currently not listening, we skip (the actualReceiver < subscriber)
func (*Broadcaster[TData]) PublishWithContext ¶ added in v0.0.599
func (bb *Broadcaster[TData]) PublishWithContext(ctx context.Context, data TData) (subscriber int, actualReceiver int, err error)
PublishWithContext sends `data` to all subscriber buffered - if one is currently not listening, we wait (but error out when the context runs out)
func (*Broadcaster[TData]) PublishWithTimeout ¶ added in v0.0.599
func (bb *Broadcaster[TData]) PublishWithTimeout(data TData, timeout time.Duration) (subscriber int, actualReceiver int)
PublishWithTimeout sends `data` to all subscriber buffered - if one is currently not listening, we wait (but wait at most `timeout` - if the timeout is exceeded then actualReceiver < subscriber)
func (*Broadcaster[TData]) SubscribeByCallback ¶ added in v0.0.599
func (bb *Broadcaster[TData]) SubscribeByCallback(fn func(TData)) BroadcastSubscription
func (*Broadcaster[TData]) SubscribeByChan ¶ added in v0.0.599
func (bb *Broadcaster[TData]) SubscribeByChan(chanBufferSize int) (chan TData, BroadcastSubscription)
func (*Broadcaster[TData]) SubscribeByIter ¶ added in v0.0.599
func (bb *Broadcaster[TData]) SubscribeByIter(chanBufferSize int) (iter.Seq[TData], BroadcastSubscription)
func (*Broadcaster[TData]) SubscriberCount ¶ added in v0.0.599
func (bb *Broadcaster[TData]) SubscriberCount() int
type BufferedReadCloser ¶
type BufferedReadCloser interface {
io.ReadCloser
BufferedAll() ([]byte, error)
Reset() error
}
func NewBufferedReadCloser ¶
func NewBufferedReadCloser(sub io.ReadCloser) BufferedReadCloser
type CASMutex ¶
type CASMutex struct {
// contains filtered or unexported fields
}
CASMutex is the struct implementing RWMutex with CAS mechanism.
func NewCASMutex ¶
func NewCASMutex() *CASMutex
func (*CASMutex) Lock ¶
func (m *CASMutex) Lock()
Lock acquires the lock. If it is currently held by others, Lock will wait until it has a chance to acquire it.
func (*CASMutex) RLock ¶
func (m *CASMutex) RLock()
RLock acquires the read lock. If it is currently held by others writing, RLock will wait until it has a chance to acquire it.
func (*CASMutex) RLocker ¶
RLocker returns a Locker interface that implements the Lock and Unlock methods by calling CASMutex.RLock and CASMutex.RUnlock.
func (*CASMutex) RTryLock ¶
RTryLock attempts to acquire the read lock without blocking. Return false if someone is writing it now.
func (*CASMutex) RTryLockWithContext ¶
RTryLockWithContext attempts to acquire the read lock, blocking until resources are available or ctx is done (timeout or cancellation).
func (*CASMutex) RTryLockWithTimeout ¶
RTryLockWithTimeout attempts to acquire the read lock within a period of time. Return false if spending time is more than duration and no chance to acquire it.
func (*CASMutex) TryLock ¶
TryLock attempts to acquire the lock without blocking. Return false if someone is holding it now.
func (*CASMutex) TryLockWithContext ¶
TryLockWithContext attempts to acquire the lock, blocking until resources are available or ctx is done (timeout or cancellation).
func (*CASMutex) TryLockWithTimeout ¶
TryLockWithTimeout attempts to acquire the lock within a period of time. Return false if spending time is more than duration and no chance to acquire it.
type DelayedCombiningInvoker ¶ added in v0.0.575
type DelayedCombiningInvoker struct {
// contains filtered or unexported fields
}
DelayedCombiningInvoker is a utility to combine multiple consecutive requests into a single execution
Requests are made with Request(), and consecutive requests are combined during the `delay` period.
Can be used, e.g., for search-controls, where we want to init the search when teh user stops typing Or generally to queue an execution once a burst of requests is over.
func NewDelayedCombiningInvoker ¶ added in v0.0.575
func NewDelayedCombiningInvoker(action func(), delay time.Duration, maxDelay time.Duration) *DelayedCombiningInvoker
func (*DelayedCombiningInvoker) CancelPendingRequests ¶ added in v0.0.575
func (d *DelayedCombiningInvoker) CancelPendingRequests()
func (*DelayedCombiningInvoker) CountPendingRequests ¶ added in v0.0.602
func (d *DelayedCombiningInvoker) CountPendingRequests() int
func (*DelayedCombiningInvoker) ExecuteNow ¶ added in v0.0.575
func (d *DelayedCombiningInvoker) ExecuteNow() bool
func (*DelayedCombiningInvoker) HasPendingRequests ¶ added in v0.0.575
func (d *DelayedCombiningInvoker) HasPendingRequests() bool
func (*DelayedCombiningInvoker) RegisterOnExecutionDone ¶ added in v0.0.602
func (d *DelayedCombiningInvoker) RegisterOnExecutionDone(fn func())
func (*DelayedCombiningInvoker) RegisterOnExecutionStart ¶ added in v0.0.602
func (d *DelayedCombiningInvoker) RegisterOnExecutionStart(fn func(immediately bool))
func (*DelayedCombiningInvoker) RegisterOnRequest ¶ added in v0.0.602
func (d *DelayedCombiningInvoker) RegisterOnRequest(fn func(pending int, initial bool))
func (*DelayedCombiningInvoker) Request ¶ added in v0.0.575
func (d *DelayedCombiningInvoker) Request()
func (*DelayedCombiningInvoker) WaitForCompletion ¶ added in v0.0.575
func (d *DelayedCombiningInvoker) WaitForCompletion(ctx context.Context) error
type JsonOpt ¶
type JsonOpt[T any] struct { // contains filtered or unexported fields }
func EmptyJsonOpt ¶
func NewJsonOpt ¶
func (JsonOpt[T]) MarshalJSON ¶
MarshalJSON returns m as the JSON encoding of m.
func (*JsonOpt[T]) UnmarshalJSON ¶
UnmarshalJSON sets *m to a copy of data.
func (JsonOpt[T]) ValueDblPtrOrNil ¶
func (m JsonOpt[T]) ValueDblPtrOrNil() **T
func (JsonOpt[T]) ValueOrNil ¶
func (m JsonOpt[T]) ValueOrNil() *T
type LRUMap ¶
type LRUMap[TKey comparable, TData any] struct { // contains filtered or unexported fields }
type MultiMutex ¶ added in v0.0.615
type MultiMutex[TKey comparable] struct { // contains filtered or unexported fields }
MultiMutex is a simple map[key -> mutex]
func NewMultiMutex ¶ added in v0.0.615
func NewMultiMutex[TKey comparable]() *MultiMutex[TKey]
func (*MultiMutex[TKey]) Get ¶ added in v0.0.616
func (mm *MultiMutex[TKey]) Get(key TKey) sync.Locker
Get returns a Locker interface
func (*MultiMutex[TKey]) GetCAS ¶ added in v0.0.617
func (mm *MultiMutex[TKey]) GetCAS(key TKey) *CASMutex
GetCAS returns the underlying CASMutex
func (*MultiMutex[TKey]) Lock ¶ added in v0.0.615
func (mm *MultiMutex[TKey]) Lock(key TKey)
Lock acquires the lock. If it is currently held by others, Lock will wait until it has a chance to acquire it.
func (*MultiMutex[TKey]) RLock ¶ added in v0.0.615
func (mm *MultiMutex[TKey]) RLock(key TKey)
RLock acquires the read lock. If it is currently held by others writing, RLock will wait until it has a chance to acquire it.
func (*MultiMutex[TKey]) RLocker ¶ added in v0.0.615
func (mm *MultiMutex[TKey]) RLocker(key TKey) sync.Locker
RLocker returns a Locker interface that implements the Lock and Unlock methods by calling CASMutex.RLock and CASMutex.RUnlock.
func (*MultiMutex[TKey]) RTryLock ¶ added in v0.0.615
func (mm *MultiMutex[TKey]) RTryLock(key TKey) bool
RTryLock attempts to acquire the read lock without blocking. Return false if someone is writing it now.
func (*MultiMutex[TKey]) RTryLockWithContext ¶ added in v0.0.615
func (mm *MultiMutex[TKey]) RTryLockWithContext(ctx context.Context, key TKey) bool
RTryLockWithContext attempts to acquire the read lock, blocking until resources are available or ctx is done (timeout or cancellation).
func (*MultiMutex[TKey]) RTryLockWithTimeout ¶ added in v0.0.615
func (mm *MultiMutex[TKey]) RTryLockWithTimeout(duration time.Duration, key TKey) bool
RTryLockWithTimeout attempts to acquire the read lock within a period of time. Return false if spending time is more than duration and no chance to acquire it.
func (*MultiMutex[TKey]) RUnlock ¶ added in v0.0.615
func (mm *MultiMutex[TKey]) RUnlock(key TKey)
RUnlock releases the read lock.
func (*MultiMutex[TKey]) TryLock ¶ added in v0.0.615
func (mm *MultiMutex[TKey]) TryLock(key TKey) bool
TryLock attempts to acquire the lock without blocking. Return false if someone is holding it now.
func (*MultiMutex[TKey]) TryLockWithContext ¶ added in v0.0.615
func (mm *MultiMutex[TKey]) TryLockWithContext(ctx context.Context, key TKey) bool
TryLockWithContext attempts to acquire the lock, blocking until resources are available or ctx is done (timeout or cancellation).
func (*MultiMutex[TKey]) TryLockWithTimeout ¶ added in v0.0.615
func (mm *MultiMutex[TKey]) TryLockWithTimeout(key TKey, duration time.Duration) bool
TryLockWithTimeout attempts to acquire the lock within a period of time. Return false if spending time is more than duration and no chance to acquire it.
func (*MultiMutex[TKey]) Unlock ¶ added in v0.0.615
func (mm *MultiMutex[TKey]) Unlock(key TKey)
Unlock releases the lock.
type MutexSet ¶ added in v0.0.611
type MutexSet[T comparable] struct { // contains filtered or unexported fields }
func NewMutexSet ¶ added in v0.0.611
func NewMutexSet[T comparable]() *MutexSet[T]
type Nonuple ¶
type Nonuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any, T9 any] struct { V1 T1 V2 T2 V3 T3 V4 T4 V5 T5 V6 T6 V7 T7 V8 T8 V9 T9 }
func NewNonuple ¶
func (Nonuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]) TupleLength ¶
func (Nonuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]) TupleValues ¶
type Octuple ¶
type Octuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any, T8 any] struct { V1 T1 V2 T2 V3 T3 V4 T4 V5 T5 V6 T6 V7 T7 V8 T8 }
func NewOctuple ¶
func (Octuple[T1, T2, T3, T4, T5, T6, T7, T8]) TupleLength ¶
func (Octuple[T1, T2, T3, T4, T5, T6, T7, T8]) TupleValues ¶
type PubSub ¶ added in v0.0.591
type PubSub[TNamespace comparable, TData any] struct { // contains filtered or unexported fields }
PubSub is a simple Pub/Sub Broker Clients can subscribe to a namespace and receive published messages on this namespace Messages are broadcast to all subscribers
func NewPubSub ¶ added in v0.0.591
func NewPubSub[TNamespace comparable, TData any](capacity int) *PubSub[TNamespace, TData]
func (*PubSub[TNamespace, TData]) Namespaces ¶ added in v0.0.591
func (ps *PubSub[TNamespace, TData]) Namespaces() []TNamespace
func (*PubSub[TNamespace, TData]) Publish ¶ added in v0.0.591
func (ps *PubSub[TNamespace, TData]) Publish(ns TNamespace, data TData) (subscriber int, actualReceiver int)
Publish sends `data` to all subscriber But unbuffered - if one is currently not listening, we skip (the actualReceiver < subscriber)
func (*PubSub[TNamespace, TData]) PublishWithContext ¶ added in v0.0.591
func (ps *PubSub[TNamespace, TData]) PublishWithContext(ctx context.Context, ns TNamespace, data TData) (subscriber int, actualReceiver int, err error)
PublishWithContext sends `data` to all subscriber buffered - if one is currently not listening, we wait (but error out when the context runs out)
func (*PubSub[TNamespace, TData]) PublishWithTimeout ¶ added in v0.0.591
func (ps *PubSub[TNamespace, TData]) PublishWithTimeout(ns TNamespace, data TData, timeout time.Duration) (subscriber int, actualReceiver int)
PublishWithTimeout sends `data` to all subscriber buffered - if one is currently not listening, we wait (but wait at most `timeout` - if the timeout is exceeded then actualReceiver < subscriber)
func (*PubSub[TNamespace, TData]) SubscribeByCallback ¶ added in v0.0.591
func (ps *PubSub[TNamespace, TData]) SubscribeByCallback(ns TNamespace, fn func(TData)) PubSubSubscription
func (*PubSub[TNamespace, TData]) SubscribeByChan ¶ added in v0.0.591
func (ps *PubSub[TNamespace, TData]) SubscribeByChan(ns TNamespace, chanBufferSize int) (chan TData, PubSubSubscription)
func (*PubSub[TNamespace, TData]) SubscribeByIter ¶ added in v0.0.591
func (ps *PubSub[TNamespace, TData]) SubscribeByIter(ns TNamespace, chanBufferSize int) (iter.Seq[TData], PubSubSubscription)
func (*PubSub[TNamespace, TData]) SubscriberCount ¶ added in v0.0.591
type PubSubSubscription ¶ added in v0.0.591
type PubSubSubscription interface {
Unsubscribe()
}
type Quadruple ¶
func NewQuadruple ¶
func (Quadruple[T1, T2, T3, T4]) TupleLength ¶
func (Quadruple[T1, T2, T3, T4]) TupleValues ¶
type Quintuple ¶
func NewQuintuple ¶
func (Quintuple[T1, T2, T3, T4, T5]) TupleLength ¶
func (Quintuple[T1, T2, T3, T4, T5]) TupleValues ¶
type RingBuffer ¶
type RingBuffer[T any] struct { // contains filtered or unexported fields }
func NewRingBuffer ¶
func NewRingBuffer[T any](capacity int) *RingBuffer[T]
func (*RingBuffer[T]) At ¶
func (rb *RingBuffer[T]) At(i int) T
func (*RingBuffer[T]) Capacity ¶
func (rb *RingBuffer[T]) Capacity() int
func (*RingBuffer[T]) Clear ¶
func (rb *RingBuffer[T]) Clear()
func (*RingBuffer[T]) Get ¶
func (rb *RingBuffer[T]) Get(i int) (T, bool)
func (*RingBuffer[T]) IsFull ¶
func (rb *RingBuffer[T]) IsFull() bool
func (*RingBuffer[T]) Items ¶
func (rb *RingBuffer[T]) Items() []T
func (*RingBuffer[T]) Iter ¶
func (rb *RingBuffer[T]) Iter() iter.Seq[T]
func (*RingBuffer[T]) Peek ¶
func (rb *RingBuffer[T]) Peek() (T, bool)
func (*RingBuffer[T]) Push ¶
func (rb *RingBuffer[T]) Push(item T)
func (*RingBuffer[T]) PushPop ¶
func (rb *RingBuffer[T]) PushPop(item T) *T
func (*RingBuffer[T]) Remove ¶
func (rb *RingBuffer[T]) Remove(fnEqual func(v T) bool) int
func (*RingBuffer[T]) Size ¶
func (rb *RingBuffer[T]) Size() int
type Septuple ¶
type Septuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any, T7 any] struct { V1 T1 V2 T2 V3 T3 V4 T4 V5 T5 V6 T6 V7 T7 }
func NewSeptuple ¶
func (Septuple[T1, T2, T3, T4, T5, T6, T7]) TupleLength ¶
func (Septuple[T1, T2, T3, T4, T5, T6, T7]) TupleValues ¶
type Sextuple ¶
type Sextuple[T1 any, T2 any, T3 any, T4 any, T5 any, T6 any] struct { V1 T1 V2 T2 V3 T3 V4 T4 V5 T5 V6 T6 }
func NewSextuple ¶
func (Sextuple[T1, T2, T3, T4, T5, T6]) TupleLength ¶
func (Sextuple[T1, T2, T3, T4, T5, T6]) TupleValues ¶
type Single ¶
type Single[T1 any] struct { V1 T1 }
func (Single[T1]) TupleLength ¶
func (Single[T1]) TupleValues ¶
type StructHashOptions ¶
type SyncMap ¶
type SyncMap[TKey comparable, TData any] struct { // contains filtered or unexported fields }
SyncMap is a thread-safe map implementation for generic key-value pairs. All functions aresafe to be called in parallel.
func NewSyncMap ¶
func NewSyncMap[TKey comparable, TData any]() *SyncMap[TKey, TData]
func (*SyncMap[TKey, TData]) Clear ¶ added in v0.0.574
func (s *SyncMap[TKey, TData]) Clear()
Clear removes all entries from the map.
func (*SyncMap[TKey, TData]) Count ¶ added in v0.0.575
Count returns the number of entries in the map.
func (*SyncMap[TKey, TData]) Delete ¶
Delete removes the entry with the provided key and returns true if the key existed before.
func (*SyncMap[TKey, TData]) DeleteIf ¶ added in v0.0.575
DeleteIf deletes all entries that match the provided function and returns the number of removed entries.
func (*SyncMap[TKey, TData]) GetAllKeys ¶
func (s *SyncMap[TKey, TData]) GetAllKeys() []TKey
GetAllKeys returns a copy (!) of all keys in the map.
func (*SyncMap[TKey, TData]) GetAllValues ¶
func (s *SyncMap[TKey, TData]) GetAllValues() []TData
GetAllValues returns a copy (!) of all values in the map.
func (*SyncMap[TKey, TData]) GetAndSetIfNotContains ¶
func (s *SyncMap[TKey, TData]) GetAndSetIfNotContains(key TKey, data TData) TData
GetAndSetIfNotContains returns the existing value if the key exists. Otherwise, it sets the provided value and returns it.
func (*SyncMap[TKey, TData]) GetAndSetIfNotContainsFunc ¶
func (s *SyncMap[TKey, TData]) GetAndSetIfNotContainsFunc(key TKey, data func() TData) TData
GetAndSetIfNotContainsFunc returns the existing value if the key exists. Otherwise, it calls the provided function to generate the value, sets it, and returns it.
func (*SyncMap[TKey, TData]) Set ¶
func (s *SyncMap[TKey, TData]) Set(key TKey, data TData)
Set sets the value for the provided key
func (*SyncMap[TKey, TData]) SetIfNotContains ¶
SetIfNotContains sets the value for the provided key if it does not already exist
func (*SyncMap[TKey, TData]) SetIfNotContainsFunc ¶
SetIfNotContainsFunc sets the value for the provided key using the provided function
func (*SyncMap[TKey, TData]) UpdateIfExists ¶ added in v0.0.597
UpdateIfExists updates the value if the key exists, otherwise it does nothing.
func (*SyncMap[TKey, TData]) UpdateOrInsert ¶ added in v0.0.597
func (s *SyncMap[TKey, TData]) UpdateOrInsert(key TKey, fn func(data TData) TData, insertValue TData) bool
UpdateOrInsert updates the value if the key exists, otherwise it inserts the provided `insertValue`.
type SyncRingSet ¶
type SyncRingSet[TData comparable] struct { // contains filtered or unexported fields }
func NewSyncRingSet ¶
func NewSyncRingSet[TData comparable](capacity int) *SyncRingSet[TData]
func (*SyncRingSet[TData]) Add ¶
func (s *SyncRingSet[TData]) Add(value TData) bool
Add adds `value` to the set returns true if the value was actually inserted (value did not exist beforehand) returns false if the value already existed
func (*SyncRingSet[TData]) AddAll ¶
func (s *SyncRingSet[TData]) AddAll(values []TData)
func (*SyncRingSet[TData]) AddIfNotContains ¶
func (s *SyncRingSet[TData]) AddIfNotContains(key TData) bool
AddIfNotContains returns true if the value was actually added (value did not exist beforehand) returns false if the value already existed
func (*SyncRingSet[TData]) Contains ¶
func (s *SyncRingSet[TData]) Contains(value TData) bool
func (*SyncRingSet[TData]) Get ¶
func (s *SyncRingSet[TData]) Get() []TData
func (*SyncRingSet[TData]) Remove ¶
func (s *SyncRingSet[TData]) Remove(value TData) bool
func (*SyncRingSet[TData]) RemoveAll ¶
func (s *SyncRingSet[TData]) RemoveAll(values []TData)
func (*SyncRingSet[TData]) RemoveIfContains ¶
func (s *SyncRingSet[TData]) RemoveIfContains(key TData) bool
RemoveIfContains returns true if the value was actually removed (value did exist beforehand) returns false if the value did not exist in the set
type SyncSet ¶
type SyncSet[TData comparable] struct { // contains filtered or unexported fields }
func NewSyncSet ¶
func NewSyncSet[TData comparable]() *SyncSet[TData]
func (*SyncSet[TData]) Add ¶
Add adds `value` to the set returns true if the value was actually inserted (value did not exist beforehand) returns false if the value already existed
func (*SyncSet[TData]) AddIfNotContains ¶
AddIfNotContains returns true if the value was actually added (value did not exist beforehand) returns false if the value already existed
func (*SyncSet[TData]) RemoveIfContains ¶
RemoveIfContains returns true if the value was actually removed (value did exist beforehand) returns false if the value did not exist in the set