-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathoptions.go
More file actions
30 lines (25 loc) · 723 Bytes
/
options.go
File metadata and controls
30 lines (25 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package consistenthash
type options struct {
hashFunc HashFunc
defaultReplicas uint
blockPartitioning int
}
type Option func(*options)
// WithDefaultReplicas default number of replicas to add for each key
func WithDefaultReplicas(replicas uint) Option {
return func(o *options) {
o.defaultReplicas = replicas
}
}
// WithHashFunc hash function for 32bit CH
func WithHashFunc(hashFunc HashFunc) Option {
return func(o *options) {
o.hashFunc = hashFunc
}
}
// WithBlockPartitioning uses block partitioning, divides total number of keys to the given number to get number of blocks
func WithBlockPartitioning(divisionBy int) Option {
return func(o *options) {
o.blockPartitioning = divisionBy
}
}