eetcd

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: MIT Imports: 16 Imported by: 4

README

查看全部租期

# 查看全部租期
etcdctl lease list
found 1 leases
694d79ada4e6c82c
# 查看某个租期信息
etcdctl lease timetolive 694d79ada4e6c82c --keys
lease 694d79ada4e6c82c granted with TTL(10s), remaining(9s), attached keys([/ego/main/providers/grpc://0.0.0.0:9003])

Documentation

Index

Constants

View Source
const PackageName = "component.eetcd"

Variables

This section is empty.

Functions

func DefaultConfig

func DefaultConfig() *config

DefaultConfig 返回默认配置

Types

type Component

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

Component ...

func (*Component) DelPrefix

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

DelPrefix 按前缀删除

func (*Component) GetKeyValue

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

GetKeyValue queries etcd key, returns mvccpb.KeyValue

func (*Component) GetLeaseSession

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

GetLeaseSession 创建租约会话

func (*Component) GetPrefix

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

GetPrefix get prefix

func (*Component) GetValues

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

GetValues queries etcd for keys prefixed by prefix.

func (*Component) NewMutex

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

NewMutex ...

func (*Component) WatchPrefix

func (c *Component) WatchPrefix(ctx context.Context, prefix string) (*Watch, error)

WatchPrefix 监听某个key

type Container

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

func DefaultContainer

func DefaultContainer() *Container

func Load

func Load(key string) *Container

func (*Container) Build

func (c *Container) Build(options ...Option) *Component

Build 构建组件

type Mutex

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

Mutex ...

func (*Mutex) Lock

func (mutex *Mutex) Lock(ctx context.Context) (err error)

Lock ...

func (*Mutex) Unlock

func (mutex *Mutex) Unlock(ctx context.Context) (err error)

Unlock ...

type Option

type Option func(c *Container)

func WithAddrs added in v0.2.0

func WithAddrs(addrs []string) Option

func WithCaCert added in v0.2.0

func WithCaCert(caCert string) Option

func WithCertFile added in v0.2.0

func WithCertFile(certFile string) Option

func WithEnableBasicAuth added in v0.2.0

func WithEnableBasicAuth(enable bool) Option

func WithEnableSecure added in v0.2.0

func WithEnableSecure(secure bool) Option

func WithKeyFile added in v0.2.0

func WithKeyFile(keyFile string) Option

func WithPassword added in v0.2.0

func WithPassword(password string) Option

func WithUserName added in v0.2.0

func WithUserName(userName string) Option

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

Directories

Path Synopsis
examples
helloworld
Package helloworld is a generated protocol buffer package.
Package helloworld is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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