etcdadapter

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEtcdClient

func NewEtcdClient(ctx context.Context, config *EtcdConfig) (*clientv3.Client, error)

Types

type AddrStore

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

AddrStore stores the current proxy address locally. It sets the address in etcd and watches the changes.

func NewAddrStore

func NewAddrStore(
	localAddrStore lockproxy.LocalAddrStore,
	etcdClient *clientv3.Client,
	addrKey string,
	logger *logrus.Entry,
) *AddrStore

func (*AddrStore) Addr

func (s *AddrStore) Addr(ctx context.Context) string

func (*AddrStore) Refresh added in v0.3.0

func (s *AddrStore) Refresh(ctx context.Context) (addr string, err error)

func (*AddrStore) SetAddr

func (s *AddrStore) SetAddr(ctx context.Context, addr string) error

func (*AddrStore) Start added in v0.3.0

func (s *AddrStore) Start(ctx context.Context, onStarted func()) error

type EtcdAdapter

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

func NewEtcdAdapter

func NewEtcdAdapter(config *EtcdConfig, logger *logrus.Entry) *EtcdAdapter

func (*EtcdAdapter) Close

func (a *EtcdAdapter) Close() error

func (*EtcdAdapter) GetLocker

func (a *EtcdAdapter) GetLocker(onLocked func(ctx context.Context) error) (lockproxy.Locker, error)

func (*EtcdAdapter) GetRemoteAddrStore added in v0.3.0

func (a *EtcdAdapter) GetRemoteAddrStore(localAddrStore lockproxy.LocalAddrStore) (lockproxy.RemoteAddrStore, error)

func (*EtcdAdapter) Init

func (a *EtcdAdapter) Init(ctx context.Context) error

type EtcdConfig

type EtcdConfig struct {
	// EtcdEndpoints is a comma separated list etcd server endpoints.
	// (LOCKPROXY_ETCDENDPOINTS)
	EtcdEndpoints []string `default:"localhost:2379"`

	// EtcdDialTimeout is the timeout for failing to establish an etcd connection.
	// (LOCKPROXY_ETCDDIALTIMEOUT)
	EtcdDialTimeout time.Duration `default:"10s"`

	// EtcdDialKeepAliveTime is the time after which client pings the server to
	// see if the transport is alive.
	// (LOCKPROXY_ETCDDIALKEEPALIVETIME)
	EtcdDialKeepAliveTime time.Duration `default:"10s"`

	// DialKeepAliveTimeout is the time that the client waits for a response for
	// the keep-alive probe. If the response is not received in this time, the
	// connection is closed.
	// (LOCKPROXY_ETCDDIALKEEPALIVETIMEOUT)
	EtcdDialKeepAliveTimeout time.Duration `default:"10s"`

	// EtcdUsername is an etcd user name for authentication.
	// (LOCKPROXY_ETCDUSERNAME)
	EtcdUsername string

	// EtcdPassword is an etcd password for authentication.
	// (LOCKPROXY_ETCDPASSWORD)
	EtcdPassword string

	// EtcdLockTTL is the duration of the etcd lock (in seconds). The lock will
	// be refreshed every EtcdLockTTL seconds.
	// (LOCKPROXY_ETCDLOCKTTL)
	EtcdLockTTL int `default:"10"`

	// EtcdUnlockTimeout is the max duration for waiting etcd to unlock after the
	// Cmd is stopped.
	// (LOCKPROXY_ETCDUNLOCKTIMEOUT)
	EtcdUnlockTimeout time.Duration `default:"10s"`

	// EtcdLockKey is the etcd key used for etcd lock.
	// (LOCKPROXY_ETCDLOCKKEY)
	EtcdLockKey string `required:"true"`

	// EtcdAddrKey is the etcd key used to store the address of the current
	// leader.
	// (LOCKPROXY_ETCDADDRKEY)
	EtcdAddrKey string `required:"true"`
}

type Locker

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

func NewLocker

func NewLocker(
	etcdClient *clientv3.Client,
	lockKey string,
	lockTTL int,
	unlockTimeout time.Duration,
	onLocked func(ctx context.Context) error,
	logger *logrus.Entry,
) *Locker

func (*Locker) Start

func (l *Locker) Start(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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