Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dynamic ¶
func Dynamic[T any, K comparable]( in <-chan T, keyFunc func(T) K, consumeFunc func(K, <-chan T), opts ...Option, )
Dynamic creates dynamic demultiplexer that routes items from 'in' based on keys returned by 'keyFunc'. For each unique key, a new goroutine is spawned running 'consumeFunc'. Each consumeFunc receives a channel that delivers values matching its key. When maxChannels limit is reached, least recently used channels are evicted.
func Static ¶
func Static[T any, K comparable](in <-chan T, keyFunc func(T) K, channels map[K]chan<- T)
Static creates Static demultipler that routes each element to channel in channels map by key computed by keyFunc.
Types ¶
type Config ¶ added in v0.0.3
type Config struct {
// contains filtered or unexported fields
}
Config holds configuration for the dynamic demultiplexer
type Option ¶ added in v0.0.3
type Option func(*Config)
Option is a functional option for configuring the demultiplexer
func WithBufferSize ¶ added in v0.0.3
WithBufferSize sets the buffer size for each channel
func WithMaxChannels ¶ added in v0.0.3
WithMaxChannels sets the maximum number of concurrent channels