Documentation ¶
Index ¶
Constants ¶
View Source
const ( SafeWriteTimeout = time.Duration(100) * time.Millisecond DefaultBroadcastChannelSize = 8 )
View Source
const DefaultRingBufferSize = 16384
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Broadcaster ¶ added in v0.3.29
type Broadcaster[T any] struct { // contains filtered or unexported fields }
func NewBroadcaster ¶ added in v0.3.29
func NewBroadcaster[T any](bufferSize int) *Broadcaster[T]
func (*Broadcaster[T]) Broadcast ¶ added in v0.3.29
func (b *Broadcaster[T]) Broadcast(data T) error
Broadcast will send the provided T to all currently subscribed channels as long as the channel is not full (which would cause the broadcaster to block until there was space on that channel).
func (*Broadcaster[T]) Close ¶ added in v0.3.29
func (b *Broadcaster[T]) Close()
func (*Broadcaster[T]) IsClosed ¶ added in v0.3.29
func (b *Broadcaster[T]) IsClosed() bool
func (*Broadcaster[T]) SetAutoclose ¶ added in v0.3.29
func (b *Broadcaster[T]) SetAutoclose(val bool)
func (*Broadcaster[T]) Subscribe ¶ added in v0.3.29
func (b *Broadcaster[T]) Subscribe() (chan T, error)
Subscribe allows a client to request future entries and it does this by listening to the channel it is provided.
func (*Broadcaster[T]) Unsubscribe ¶ added in v0.3.29
func (b *Broadcaster[T]) Unsubscribe(ch chan T)
Unsubscribe will remove the provided channel (which should have come from a previous call to Subscribe)
type RingBuffer ¶ added in v0.3.29
type RingBuffer[T any] struct { // contains filtered or unexported fields }
func NewRingBuffer ¶ added in v0.3.29
func NewRingBuffer[T any](size int) *RingBuffer[T]
func (*RingBuffer[T]) Dequeue ¶ added in v0.3.29
func (r *RingBuffer[T]) Dequeue() T
func (*RingBuffer[T]) Drain ¶ added in v0.3.29
func (r *RingBuffer[T]) Drain() []T
func (*RingBuffer[T]) Each ¶ added in v0.3.29
func (r *RingBuffer[T]) Each(f func(any))
func (*RingBuffer[T]) Enqueue ¶ added in v0.3.29
func (r *RingBuffer[T]) Enqueue(data T)
Enqueue will continue to write data to the ring buffer even if nothing is reading from it.
type SyncMap ¶
type SyncMap[K comparable, V any] struct { sync.Map }
A SyncMap is a concurrency-safe sync.Map that uses strongly-typed method signatures to ensure the types of its stored data are known.
func SyncMapFromMap ¶
func SyncMapFromMap[K comparable, V any](m map[K]V) *SyncMap[K, V]
Click to show internal directories.
Click to hide internal directories.