Etcd

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ATTR_WithPrevKV = "WithPrevKV" //过期时间
	ATTR_Lease      = "Lease"      // setnx
	ATTR_WithTime   = "WithTime"   // setxx
)

可添加的属性

Variables

Functions

func ReleaseEtcdCache

func ReleaseEtcdCache(cache *EtcdCtl)

Types

type EtcdCtl

type EtcdCtl struct {
	EtcdClient *clientv3.Client `inject:"-"`
	// contains filtered or unexported fields
}

func EtcdCache

func EtcdCache() *EtcdCtl

func New

func New() *EtcdCtl

func (*EtcdCtl) Del

func (this *EtcdCtl) Del(key string, attrs ...*OperationAttr) *Result.ErrorResult

删除操作

func (*EtcdCtl) DelLease

func (this *EtcdCtl) DelLease(key clientv3.LeaseID) *Result.ErrorResult

删除租约

func (*EtcdCtl) Get

func (this *EtcdCtl) Get(key string, attrs ...*OperationAttr) *Result.ErrorResult

取值

func (*EtcdCtl) KeepAlive

func (this *EtcdCtl) KeepAlive(LeaseID clientv3.LeaseID)

续租

func (*EtcdCtl) KeepAliveWithContext

func (this *EtcdCtl) KeepAliveWithContext(ctx context.Context, LeaseID clientv3.LeaseID)

func (*EtcdCtl) Lease

func (this *EtcdCtl) Lease(time int64) clientv3.LeaseID

创建租约

func (*EtcdCtl) LoadService

func (this *EtcdCtl) LoadService(name string) []LoadBalance.NodeBalance

取得数据

func (*EtcdCtl) Lock

func (this *EtcdCtl) Lock(lockName string, fn func(params ...any), params ...any) error

func (*EtcdCtl) Name

func (this *EtcdCtl) Name() string

实现bean接口

func (*EtcdCtl) Put

func (this *EtcdCtl) Put(key string, value string, attrs ...*OperationAttr) Result.Any

插入数据

func (*EtcdCtl) RegService

func (this *EtcdCtl) RegService(info ServiceInfo)

注册服务

func (*EtcdCtl) Seletor

func (this *EtcdCtl) Seletor(Services LoadBalance.NodeBalanceSlice, selectType int, ip string) (LoadBalance.NodeBalance, error)

选择器

func (*EtcdCtl) UnregService

func (this *EtcdCtl) UnregService(id string)

反注册服务

type OperationAttr

type OperationAttr struct {
	Name  string
	Value any
}

属性

func WithLease

func WithLease(Lease clientv3.LeaseID) *OperationAttr

func WithPrevKV

func WithPrevKV() *OperationAttr

func WithTime

func WithTime(time int64) *OperationAttr

type OperationAttrs

type OperationAttrs []*OperationAttr

func (OperationAttrs) Find

func (this OperationAttrs) Find(name string) *Result.ErrorResult

查找对应属性限制传入的参数

type ServiceInfo

type ServiceInfo struct {
	ServiceID   string
	ServiceName string
	ServiceAddr string
	ServiceType string
	ServiceHost string
	*LoadBalance.DefaultBalance
}

func (*ServiceInfo) GetNode

func (this *ServiceInfo) GetNode() interface{}

Jump to

Keyboard shortcuts

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