micro/sync/sync.go
Vasiliy Tolstov 5eb0e56373 move all imports to own domain
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-02 19:55:07 +03:00

34 lines
787 B
Go

// Package sync is an interface for distributed synchronization
package sync // import "go.unistack.org/micro/v3/sync"
import (
"errors"
)
// ErrLockTimeout error
var ErrLockTimeout = errors.New("lock timeout")
// Sync is an interface for distributed synchronization
type Sync interface {
// Initialise 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
}