lockers

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCanceled = errors.New("canceled")
)
View Source
var LockerTypes = []string{
	"consul",
}
View Source
var Lockers = map[string]Initializer{}

Functions

func DecodeConfig

func DecodeConfig(src, dst interface{}) error

func Register

func Register(name string, initFn Initializer)

Types

type Initializer

type Initializer func() Locker

type Locker

type Locker interface {
	Init(context.Context, map[string]interface{}, ...Option) error

	Lock(context.Context, string, []byte) (bool, error)
	KeepLock(context.Context, string) (chan struct{}, chan error)
	IsLocked(context.Context, string) (bool, error)
	Unlock(context.Context, string) error

	Register(context.Context, *ServiceRegistration) error
	Deregister(string) error

	List(context.Context, string) (map[string]string, error)
	WatchServices(context.Context, string, []string, chan<- []*Service, time.Duration) error

	Stop() error
	SetLogger(*log.Logger)
}

type Option

type Option func(Locker)

func WithLogger

func WithLogger(logger *log.Logger) Option

type Service added in v0.8.0

type Service struct {
	ID      string
	Address string
	Tags    []string
}

type ServiceRegistration added in v0.8.0

type ServiceRegistration struct {
	ID      string
	Name    string
	Address string
	Port    int
	Tags    []string
	TTL     time.Duration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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