etcd

package
v1.20.2 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "etcd"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enable      bool          `env:"ETCD_ENABLE" default:"false" yaml:"enable"`
	Endpoints   string        `env:"ETCD_ENDPOINTS" default:"localhost:2379" yaml:"host"`
	DialTimeout time.Duration `env:"ETCD_DIAL_TIMEOUT" default:"5m" yaml:"dialTimeout"`
}

type Leader added in v1.6.0

type Leader struct {
	// contains filtered or unexported fields
}

func NewLeader added in v1.6.0

func NewLeader(e *clientv3.Client, l logrus.FieldLogger, serviceID string, opts ...LeaderOption) *Leader

func (*Leader) Acquire added in v1.6.0

func (lead *Leader) Acquire() error

func (*Leader) Close added in v1.6.0

func (lead *Leader) Close() error

func (*Leader) IsLeader added in v1.6.0

func (lead *Leader) IsLeader() bool

func (*Leader) Resign added in v1.6.0

func (lead *Leader) Resign() error

type LeaderOption added in v1.6.0

type LeaderOption func(lead *Leader) error

func WithElectionKey added in v1.6.0

func WithElectionKey(key string) LeaderOption

func WithElectionPrefix added in v1.6.0

func WithElectionPrefix(prefix string) LeaderOption

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

func New

func New() *Plugin

func (*Plugin) Boot

func (p *Plugin) Boot(conf interface{}, dependencies ...interface{}) plugins.Plugin

func (*Plugin) Close

func (p *Plugin) Close() error

func (*Plugin) Etcd

func (p *Plugin) Etcd() *clientv3.Client

func (*Plugin) IsEnabled

func (p *Plugin) IsEnabled() bool

func (*Plugin) Leader added in v1.6.0

func (p *Plugin) Leader(opts ...LeaderOption) *Leader

func (*Plugin) Lock

func (p *Plugin) Lock(key string, do func() error) error

func (*Plugin) LockWithContext

func (p *Plugin) LockWithContext(ctx context.Context, key string, do func() error) error

func (*Plugin) LockWithTTL

func (p *Plugin) LockWithTTL(key string, ttl time.Duration, do func() error) error

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Start

func (p *Plugin) Start() error

Jump to

Keyboard shortcuts

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