Documentation
¶
Overview ¶
Package sync is an interface for distributed synchronization
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrLockTimeout = errors.New("lock timeout")
)
Functions ¶
This section is empty.
Types ¶
type Leader ¶ added in v2.5.0
type Leader interface {
// resign leadership
Resign() error
// status returns when leadership is lost
Status() chan bool
}
Leader provides leadership election
type LeaderOption ¶ added in v2.5.0
type LeaderOption func(o *LeaderOptions)
type LeaderOptions ¶ added in v2.5.0
type LeaderOptions struct{}
type LockOption ¶ added in v2.5.0
type LockOption func(o *LockOptions)
func LockWait ¶ added in v2.5.0
func LockWait(t time.Duration) LockOption
LockWait sets the wait time
type Sync ¶ added in v2.5.0
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
}
Sync is an interface for distributed synchronization
Click to show internal directories.
Click to hide internal directories.