etcdc3

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrTimeout when waching wait timeout
	ErrTimeout = errors.New("watching wait timeout")
)

Functions

This section is empty.

Types

type ClientPool

type ClientPool struct {
	*PoolConfig
	// contains filtered or unexported fields
}

ClientPool of etcd clientv3, allways choose leader

func NewClientPool

func NewClientPool(config *PoolConfig) (*ClientPool, error)

NewClientPool return a new etcdc3 pool

func (*ClientPool) AllClient

func (p *ClientPool) AllClient() map[string]*c3.Client

AllClient return all client's

func (*ClientPool) Close

func (p *ClientPool) Close()

Close release all resources

func (*ClientPool) Init

func (p *ClientPool) Init() error

Init start health check, connect pool to each etcd member

func (*ClientPool) NewClientv3

func (p *ClientPool) NewClientv3(endpoints []string) (*c3.Client, error)

NewClientv3 return a new v3 client, DON't forget to close it

func (*ClientPool) Select

func (p *ClientPool) Select() (c *c3.Client)

Select return a client

func (*ClientPool) SelectWithNotify

func (p *ClientPool) SelectWithNotify() (c *c3.Client, errc chan error)

SelectWithNotify return client with err notify

type PoolConfig

type PoolConfig struct {
	Ctx     context.Context
	TestKey string
	// for health tick
	HealthTick time.Duration
	// etcd Endpoints
	Endpoints []string // store Endpoints
	TLS       *tls.Config
	// Username/Password
	Username string
	Password string

	// dail to etcd
	DialTimeout       time.Duration
	DialKeepAliveTime time.Duration
}

PoolConfig config etcd pool

Jump to

Keyboard shortcuts

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