diff --git a/sync/options.go b/sync/options.go deleted file mode 100644 index c6f2d5591e..0000000000 --- a/sync/options.go +++ /dev/null @@ -1,58 +0,0 @@ -package sync - -import ( - "context" - "crypto/tls" - "time" - - "go-micro.dev/v5/logger" -) - -// Nodes sets the addresses to use. -func Nodes(a ...string) Option { - return func(o *Options) { - o.Nodes = a - } -} - -// Prefix sets a prefix to any lock ids used. -func Prefix(p string) Option { - return func(o *Options) { - o.Prefix = p - } -} - -// LockTTL sets the lock ttl. -func LockTTL(t time.Duration) LockOption { - return func(o *LockOptions) { - o.TTL = t - } -} - -// LockWait sets the wait time. -func LockWait(t time.Duration) LockOption { - return func(o *LockOptions) { - o.Wait = t - } -} - -// WithTLS sets the TLS config. -func WithTLS(t *tls.Config) Option { - return func(o *Options) { - o.TLSConfig = t - } -} - -// WithContext sets the syncs context, for any extra configuration. -func WithContext(c context.Context) Option { - return func(o *Options) { - o.Context = c - } -} - -// WithLogger sets the underline logger. -func WithLogger(l logger.Logger) Option { - return func(o *Options) { - o.Logger = l - } -} diff --git a/sync/sync.go b/sync/sync.go deleted file mode 100644 index 1b36d1a5fa..0000000000 --- a/sync/sync.go +++ /dev/null @@ -1,60 +0,0 @@ -// Package sync is an interface for distributed synchronization -package sync - -import ( - "context" - "crypto/tls" - "errors" - "time" - - "go-micro.dev/v5/logger" -) - -var ( - ErrLockTimeout = errors.New("lock timeout") -) - -// Sync is an interface for distributed synchronization. -type Sync interface { - // Initialize options - Init(...Option) error - // Return the options - Options() Options - // Elect a leader - Leader(id string, opts ...LeaderOption) (Leader, error) - // Lock acquires a lock - Lock(id string, opts ...LockOption) error - // Unlock releases a lock - Unlock(id string) error - // Sync implementation - String() string -} - -// Leader provides leadership election. -type Leader interface { - // resign leadership - Resign() error - // status returns when leadership is lost - Status() chan bool -} - -type Options struct { - Context context.Context - Logger logger.Logger - TLSConfig *tls.Config - Prefix string - Nodes []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)