27 lines
375 B
Go
27 lines
375 B
Go
package consistencehash
|
|
|
|
type Options struct {
|
|
replicas int
|
|
lockExpire int
|
|
}
|
|
|
|
type Option func(o *Options)
|
|
|
|
func (o *Options) repire() {
|
|
if o.replicas <= 0 {
|
|
o.replicas = 5
|
|
}
|
|
}
|
|
|
|
func WithReplicas(replicas int) Option {
|
|
return func(o *Options) {
|
|
o.replicas = replicas
|
|
}
|
|
}
|
|
|
|
func WithLockExpire(expire int)Option{
|
|
return func(o *Options) {
|
|
o.lockExpire=expire
|
|
}
|
|
}
|