etcdv3

package
v0.0.0-...-2ebd195 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_CHANNEL_SIZE = 64
)

Variables

View Source
var Once sync.Once

Functions

This section is empty.

Types

type EtcdRegister

type EtcdRegister struct {
	Etcd3Client *etcd3.Client
	Logger      *zap.Logger
	Key         string //service uniq-key
	Value       string //micro-service ip+port+weight
	Ttl         time.Duration
	Ctx         context.Context
	Cancel      context.CancelFunc
	ApiOn       bool
	Leaseid     etcd3.LeaseID
}

func NewRegister

func NewRegister(config *com.RegisterConfig) (*EtcdRegister, error)

func (*EtcdRegister) ServiceRegister

func (r *EtcdRegister) ServiceRegister() error

func (*EtcdRegister) ServiceUnRegister

func (r *EtcdRegister) ServiceUnRegister() error

type EtcdResolver

type EtcdResolver struct {
	Schemename string
	EtcdCli    *etcd3.Client // etcd3 client
	WatchKey   string
	Watcher    *EtcdWatcher
	Clientconn resolver.ClientConn
	Wg         sync.WaitGroup
	//CloseCh    chan struct{} // 关闭 channel
	Logger *zap.Logger

	//control
	Ctx    *context.Context
	Cancel context.CancelFunc
}

func NewResolverRegister

func NewResolverRegister(config *com.ResolverConfig) (*EtcdResolver, error)

func (*EtcdResolver) Build

Build returns itself for resolver, because it's both a builder and a resolver.

func (*EtcdResolver) Close

func (r *EtcdResolver) Close()

Close is a noop for resolver.

func (*EtcdResolver) ResolveNow

func (r *EtcdResolver) ResolveNow(o resolver.ResolveNowOptions)

ResolveNow is a noop for resolver.

func (*EtcdResolver) Scheme

func (r *EtcdResolver) Scheme() string

Scheme returns the scheme.

type EtcdWatcher

type EtcdWatcher struct {
	WatchKey  string
	Client    *etcd3.Client
	Ctx       *context.Context
	Cancel    context.CancelFunc
	AddrsList []resolver.Address
	WatchCh   etcd3.WatchChan // watch() RETURN channel
	Logger    *zap.Logger
	Wg        *sync.WaitGroup
}

独立封装watcher

func NewEtcdWatcher

func NewEtcdWatcher(ctx *context.Context, key string, etcdclient *etcd3.Client, zaploger *zap.Logger, wg *sync.WaitGroup) *EtcdWatcher

create a etcd watcher,which belongs to etcd resolver

func (*EtcdWatcher) Close

func (w *EtcdWatcher) Close()

func (*EtcdWatcher) ExtractAddrs

func (w *EtcdWatcher) ExtractAddrs(etcdresponse *etcd3.GetResponse) []com.ServiceBasicInfo

get keys from etcdctl response

func (*EtcdWatcher) GetAllAddresses

func (w *EtcdWatcher) GetAllAddresses() []resolver.Address

sync full addrs

Jump to

Keyboard shortcuts

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