Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
func Generate[T any](in ...T) <-chan T
Generate takes a variadic input of any type T and returns a read-only channel of type T. It sends each input value into the returned channel in a separate goroutine.
func Merge ¶
func Merge[T any](in ...<-chan T) chan T
Merge combines multiple input channels into a single output channel. It starts a goroutine for each input channel to forward its values to the output channel. Once all input channels are processed, the output channel is closed.
Types ¶
type Shard ¶
type Shard[K comparable, V any] struct { // contains filtered or unexported fields }
Shard represents a single partition of a sharded key-value store. It holds a map of keys (of type K) to values (of type V), and a mutex for thread-safety.
type Sharding ¶
type Sharding[K comparable, V any] []Shard[K, V]
Sharding is a collection of Shard objects, each representing a separate partition of the key-value store. This allows for distributing keys across multiple shards.
func NewSharding ¶
func NewSharding[K comparable, V any](num int) Sharding[K, V]
NewSharding creates an array of Shard objects with the given number of shards.
func (Sharding[K, V]) Delete ¶
func (a Sharding[K, V]) Delete(key K)
Delete removes a key-value pair from the appropriate shard.