etcdv3

package
v3.2.37 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*clientv3.Client
	// contains filtered or unexported fields
}

Client ...

func (*Client) DelPrefix

func (client *Client) DelPrefix(ctx context.Context, prefix string) (deleted int64, err error)

DelPrefix 按前缀删除

func (*Client) GetKeyValue

func (client *Client) GetKeyValue(ctx context.Context, key string) (kv *mvccpb.KeyValue, err error)

GetKeyValue queries etcd key, returns mvccpb.KeyValue

func (*Client) GetLeaseSession

func (client *Client) GetLeaseSession(ctx context.Context, opts ...concurrency.SessionOption) (leaseSession *concurrency.Session, err error)

GetLeaseSession 创建租约会话

func (*Client) GetPrefix

func (client *Client) GetPrefix(ctx context.Context, prefix string) (map[string]string, error)

GetPrefix get prefix

func (*Client) GetValues

func (client *Client) GetValues(ctx context.Context, keys ...string) (map[string]string, error)

GetValues queries etcd for keys prefixed by prefix.

func (*Client) NewMutex

func (client *Client) NewMutex(key string, opts ...concurrency.SessionOption) (mutex *Mutex, err error)

NewMutex ...

func (*Client) WatchPrefix

func (client *Client) WatchPrefix(ctx context.Context, prefix string) (*Watch, error)

WatchPrefix NewWatch ...

type Config

type Config struct {
	Name             string        `json:"name"`
	Endpoints        []string      `json:"endpoints"`
	CertFile         string        `json:"certFile"`
	KeyFile          string        `json:"keyFile"`
	CaCert           string        `json:"caCert"`
	BasicAuth        bool          `json:"basicAuth"`
	UserName         string        `json:"userName"`
	Password         string        `json:"-"`
	ConnectTimeout   time.Duration `json:"connectTimeout"` // 连接超时时间
	Secure           bool          `json:"secure"`
	AutoSyncInterval time.Duration `json:"autoAsyncInterval"` // 自动同步member list的间隔
	EnableTrace      bool          `json:"enableTrace" toml:"enableTrace"`
	TTL              int           // 单位:s
}

Config ...

func New

func New() *Config

New 新建连接

func (*Config) Build

func (config *Config) Build() (*Client, error)

Build ...

func (*Config) GetName added in v3.2.29

func (config *Config) GetName() string

func (*Config) MustBuild

func (config *Config) MustBuild() *Client

func (*Config) MustSingleton added in v3.2.29

func (config *Config) MustSingleton() *Client

func (*Config) SetAutoSyncInterval added in v3.2.24

func (config *Config) SetAutoSyncInterval(autoSyncInterval time.Duration) *Config

SetAutoSyncInterval ...

func (*Config) SetBasicAuth added in v3.2.24

func (config *Config) SetBasicAuth(auth bool) *Config

SetBasicAuth ...

func (*Config) SetCaCert added in v3.2.24

func (config *Config) SetCaCert(ca string) *Config

SetCaCert ...

func (*Config) SetCertFile added in v3.2.24

func (config *Config) SetCertFile(cert string) *Config

SetCertFile ...

func (*Config) SetConnectTimeout added in v3.2.24

func (config *Config) SetConnectTimeout(timeout time.Duration) *Config

SetConnectTimeout ...

func (*Config) SetEnableTrace added in v3.2.29

func (config *Config) SetEnableTrace(enableTrace bool) *Config

SetEnableTrace ...

func (*Config) SetEndpoints added in v3.2.24

func (config *Config) SetEndpoints(endpoint []string) *Config

SetEndpoints ...

func (*Config) SetKeyFile added in v3.2.24

func (config *Config) SetKeyFile(key string) *Config

SetKeyFile ...

func (*Config) SetName added in v3.2.29

func (config *Config) SetName(Name string) *Config

SetName ...

func (*Config) SetPassword added in v3.2.24

func (config *Config) SetPassword(pwd string) *Config

SetPassword ...

func (*Config) SetSecure added in v3.2.24

func (config *Config) SetSecure(secure bool) *Config

SetSecure ...

func (*Config) SetUserName added in v3.2.25

func (config *Config) SetUserName(userName string) *Config

SetUserName ...

func (*Config) Singleton added in v3.2.29

func (config *Config) Singleton() (*Client, error)

type Mutex

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

Mutex ...

func (*Mutex) Lock

func (mutex *Mutex) Lock(timeout time.Duration) (err error)

Lock ...

func (*Mutex) TryLock

func (mutex *Mutex) TryLock(timeout time.Duration) (err error)

TryLock ...

func (*Mutex) Unlock

func (mutex *Mutex) Unlock() (err error)

Unlock ...

type Watch

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

Watch A watch only tells the latest revision

func (*Watch) C

func (w *Watch) C() chan *clientv3.Event

C ...

func (*Watch) Close

func (w *Watch) Close() error

Close close watch

func (*Watch) IncipientKeyValues

func (w *Watch) IncipientKeyValues() []*mvccpb.KeyValue

IncipientKeyValues incipient key and values

Jump to

Keyboard shortcuts

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