Documentation ¶
Index ¶
Constants ¶
View Source
const BadScheme = "sharding: uninitialised scheme"
BadScheme is the panic message for a Scheme that was not created with the New function.
Variables ¶
View Source
var ErrBadSchemeParameter = errors.New("sharding: bad scheme parameter")
ErrBadSchemeParameter is returned when a scheme is badly defined.
Functions ¶
This section is empty.
Types ¶
type Scheme ¶
type Scheme struct {
// contains filtered or unexported fields
}
Scheme is a sharding scheme for a specific number of shards, N. A scheme returns the index, [0, N), to a shard given a byte slice (see WithBytes) or a raw hash value (see WithHash). The implementation uses bit masking, so the number of shards must be a power of two.
func New ¶
New returns a sharding scheme for the given number of shards. That number must be a power of two.
Click to show internal directories.
Click to hide internal directories.