2019-05-31 02:43:23 +03:00
|
|
|
package sync
|
|
|
|
|
|
|
|
import (
|
2020-04-11 12:37:54 +03:00
|
|
|
"time"
|
2019-05-31 02:43:23 +03:00
|
|
|
)
|
|
|
|
|
2020-04-11 12:37:54 +03:00
|
|
|
// Nodes sets the addresses to use
|
|
|
|
func Nodes(a ...string) Option {
|
2019-05-31 02:43:23 +03:00
|
|
|
return func(o *Options) {
|
2020-04-11 12:37:54 +03:00
|
|
|
o.Nodes = a
|
2019-05-31 02:43:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-11 12:37:54 +03:00
|
|
|
// Prefix sets a prefix to any lock ids used
|
|
|
|
func Prefix(p string) Option {
|
2019-05-31 02:43:23 +03:00
|
|
|
return func(o *Options) {
|
2020-04-11 12:37:54 +03:00
|
|
|
o.Prefix = p
|
2019-05-31 02:43:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-11 12:37:54 +03:00
|
|
|
// LockTTL sets the lock ttl
|
|
|
|
func LockTTL(t time.Duration) LockOption {
|
|
|
|
return func(o *LockOptions) {
|
|
|
|
o.TTL = t
|
2019-05-31 02:43:23 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-11 12:37:54 +03:00
|
|
|
// LockWait sets the wait time
|
|
|
|
func LockWait(t time.Duration) LockOption {
|
|
|
|
return func(o *LockOptions) {
|
|
|
|
o.Wait = t
|
2019-05-31 02:43:23 +03:00
|
|
|
}
|
|
|
|
}
|