sync

package
v0.20.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2021 License: MIT Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

type Leader interface {
	// Resign resign leadership
	Resign() error
	// Status returns when leadership is lost
	Status() chan bool
}

Leader provides leadership election

type LeaderOption

type LeaderOption func(o *LeaderOptions)

type LeaderOptions

type LeaderOptions struct{}

type LockOption

type LockOption func(o *LockOptions)

func LockTTL

func LockTTL(t time.Duration) LockOption

LockTTL sets the lock ttl

func LockWait

func LockWait(t time.Duration) LockOption

LockWait sets the wait time

type LockOptions

type LockOptions struct {
	TTL  time.Duration
	Wait time.Duration
}

type Option

type Option func(o *Options)

func Nodes

func Nodes(a ...string) Option

Nodes sets the addresses to use

func Prefix

func Prefix(p string) Option

Prefix sets a prefix to any lock ids used

type Options

type Options struct {
	Nodes  []string
	Prefix string
}

type Sync

type Sync interface {
	// Init Initialise options
	Init(...Option) error
	// Options Return the options
	Options() Options
	// Leader 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
	// String Sync implementation
	String() string
}

Sync is an interface for distributed synchronization

Directories

Path Synopsis
Package memory provides a sync.Mutex implementation of the lock for local use
Package memory provides a sync.Mutex implementation of the lock for local use

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL