Help us shape the future of Go! Take the 2026 Go Developer Survey

lockers

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 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",
	"k8s",
}
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)
	GetServices(ctx context.Context, serviceName string, tags []string) ([]*Service, error)
	WatchServices(ctx context.Context, serviceName string, tags []string, ch chan<- []*Service, dur 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