Documentation
¶
Index ¶
- Variables
- func Assign(keys, nodes []string, opts ...Option) (map[string]string, error)
- func Owner(key string, nodes []string, opts ...Option) (string, error)
- func OwnerW(key string, nodes []WeightedNode, opts ...Option) (string, error)
- func Owners(key string, nodes []string, n int, opts ...Option) ([]string, error)
- type Option
- type Skeleton
- type Weighted
- type WeightedNode
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Assign ¶
Assign maps every key to a node, bounding each node's load at ceil(len(keys)/len(nodes) * (1+epsilon)). Keys and nodes are deduped; the result is a pure function of the inputs. O(k*n).
Types ¶
type Option ¶
type Option func(*config)
Option configures scoring and skeleton construction.
func WithClusterSize ¶
WithClusterSize sets the skeleton cluster size (default 16).
func WithEpsilon ¶
WithEpsilon sets the load slack factor for Assign (default 0.25).
func WithFanout ¶
WithFanout sets the skeleton branching factor (default: auto).
type Skeleton ¶
type Skeleton struct {
// contains filtered or unexported fields
}
Skeleton is a precomputed clustered tree enabling O(log n) lookups. Plain data; build once with Build or BuildW, reuse across calls.
type Weighted ¶
type Weighted struct{}
Weighted implements weighted rendezvous scoring: score = pow(hash01, 1/weight). Higher weight biases keys toward the node.
type WeightedNode ¶
WeightedNode pairs a node with a positive weight.