add logger to options

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-08-29 17:44:49 +03:00
parent 2382446e10
commit 53654185ba
16 changed files with 239 additions and 48 deletions

View File

@@ -2,8 +2,36 @@ package sync
import (
"time"
"github.com/unistack-org/micro/v3/logger"
)
type Options struct {
Nodes []string
Prefix string
Logger logger.Logger
}
type Option func(o *Options)
type LeaderOptions struct{}
type LeaderOption func(o *LeaderOptions)
type LockOptions struct {
TTL time.Duration
Wait time.Duration
}
type LockOption func(o *LockOptions)
// Logger sets the logger
func Logger(l logger.Logger) Option {
return func(o *Options) {
o.Logger = l
}
}
// Nodes sets the addresses to use
func Nodes(a ...string) Option {
return func(o *Options) {

View File

@@ -3,7 +3,6 @@ package sync
import (
"errors"
"time"
)
var (
@@ -33,21 +32,3 @@ type Leader interface {
// status returns when leadership is lost
Status() chan bool
}
type Options struct {
Nodes []string
Prefix string
}
type Option func(o *Options)
type LeaderOptions struct{}
type LeaderOption func(o *LeaderOptions)
type LockOptions struct {
TTL time.Duration
Wait time.Duration
}
type LockOption func(o *LockOptions)