etcd

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2020 License: MIT Imports: 10 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) (*clientv3.DeleteResponse, error)

func (*EtcdCtl) DelLease

func (this *EtcdCtl) DelLease(key clientv3.LeaseID) (*clientv3.LeaseRevokeResponse, error)

func (*EtcdCtl) Get

func (this *EtcdCtl) Get(key string, attrs ...*OperationAttr) (*clientv3.GetResponse, error)

func (*EtcdCtl) KeepAlive

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

func (*EtcdCtl) KeepAliveWithContext

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

func (*EtcdCtl) Lease

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

func (*EtcdCtl) LoadService

func (this *EtcdCtl) LoadService(name string) ([]*ServiceInfo, error)

func (*EtcdCtl) Lock

func (this *EtcdCtl) Lock(lockName string, fn func(params ...interface{}), params ...interface{}) error

func (*EtcdCtl) Name

func (this *EtcdCtl) Name() string

func (*EtcdCtl) Put

func (this *EtcdCtl) Put(key string, value string, attrs ...*OperationAttr) interface{}

func (*EtcdCtl) RegService

func (this *EtcdCtl) RegService(info ServiceInfo)

注册服务

func (*EtcdCtl) Seletor

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

func (*EtcdCtl) UnregService

func (this *EtcdCtl) UnregService(id string) error

反注册服务

type OperationAttr

type OperationAttr struct {
	Name  string
	Value interface{}
}

属性

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
	ServiceWight int
	Status       string
	CWeight      int
}

func (*ServiceInfo) GetCWeight

func (this *ServiceInfo) GetCWeight() int

func (*ServiceInfo) GetNode

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

func (*ServiceInfo) GetStatus

func (this *ServiceInfo) GetStatus() string

func (*ServiceInfo) GetWeight

func (this *ServiceInfo) GetWeight() int

func (*ServiceInfo) SetCWeight

func (this *ServiceInfo) SetCWeight(val int)

Jump to

Keyboard shortcuts

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