add logger to options
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -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) {
|
||||
|
||||
19
sync/sync.go
19
sync/sync.go
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user