2019-05-31 00:43:23 +01:00
|
|
|
package sync
|
|
|
|
|
|
|
|
import (
|
2020-01-30 14:39:00 +03:00
|
|
|
"github.com/micro/go-micro/v2/store"
|
|
|
|
"github.com/micro/go-micro/v2/sync/leader"
|
|
|
|
"github.com/micro/go-micro/v2/sync/lock"
|
|
|
|
"github.com/micro/go-micro/v2/sync/time"
|
2019-05-31 00:43:23 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// WithLeader sets the leader election implementation opton
|
|
|
|
func WithLeader(l leader.Leader) Option {
|
|
|
|
return func(o *Options) {
|
|
|
|
o.Leader = l
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithLock sets the locking implementation option
|
|
|
|
func WithLock(l lock.Lock) Option {
|
|
|
|
return func(o *Options) {
|
|
|
|
o.Lock = l
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-12 07:50:04 +01:00
|
|
|
// WithStore sets the store implementation option
|
|
|
|
func WithStore(s store.Store) Option {
|
2019-05-31 00:43:23 +01:00
|
|
|
return func(o *Options) {
|
2019-06-12 07:50:04 +01:00
|
|
|
o.Store = s
|
2019-05-31 00:43:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithTime sets the time implementation option
|
|
|
|
func WithTime(t time.Time) Option {
|
|
|
|
return func(o *Options) {
|
|
|
|
o.Time = t
|
|
|
|
}
|
|
|
|
}
|