Documentation
¶
Index ¶
- func NewRandom(seed int64) *random
- func NewRoundRobin() *roundRobin
- type Balancer
- type Etcd
- type EtcdDis
- func (d *EtcdDis) GetGrpcServiceInfoRandom(service string) (*ValueInfo, bool)
- func (d *EtcdDis) GetServiceInfoAllNode(service string) ([]EtcdNode, bool)
- func (d *EtcdDis) IsWatched(service string) bool
- func (d *EtcdDis) Register(keyInfo *KeyInfo, valueInfo *ValueInfo, retry bool)
- func (d *EtcdDis) Watch(service string)
- type EtcdMaster
- func (m *EtcdMaster) Close()
- func (m *EtcdMaster) DecodeKeyValue(ev *mvccpb.KeyValue) (*KeyInfo, *ValueInfo, error)
- func (m *EtcdMaster) DoWatch()
- func (m *EtcdMaster) Get()
- func (m *EtcdMaster) GetAllNodes() []EtcdNode
- func (m *EtcdMaster) GetGrpcNodeRandom() (*ValueInfo, bool)
- func (m *EtcdMaster) GetKeyInfo(key []byte) (*KeyInfo, error)
- func (m *EtcdMaster) GetPrefixPath() string
- func (m *EtcdMaster) GetValueInfo(value []byte) (*ValueInfo, error)
- func (m *EtcdMaster) NewEtcdNodes(state bool, keyInfo *KeyInfo) *EtcdNode
- func (m *EtcdMaster) ReBuildNode(keyInfo *KeyInfo)
- func (m *EtcdMaster) Stop()
- func (m *EtcdMaster) Watch()
- type EtcdNode
- type EtcdService
- func (s *EtcdService) GetInfo() ([]*mvccpb.KeyValue, error)
- func (s *EtcdService) KeepLive() (<-chan *clientv3.LeaseKeepAliveResponse, error)
- func (s *EtcdService) ReStart() error
- func (s *EtcdService) Revoke()
- func (s *EtcdService) Start() error
- func (s *EtcdService) Stop()
- func (s *EtcdService) UpdateService(status STATUS, requestFlow uint32) error
- type Hub
- type KeyInfo
- type STATUS
- type ValueInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRandom ¶
func NewRandom(seed int64) *random
NewRandom returns a load balancer that selects services randomly.
func NewRoundRobin ¶
func NewRoundRobin() *roundRobin
NewRoundRobin returns a load balancer that returns services in sequence.
Types ¶
type Etcd ¶ added in v1.1.0
func (*Etcd) SetDialKeepAlive ¶ added in v1.1.2
SetDialKeepAlive 设置keepalive时间
func (*Etcd) SetDialTimeout ¶ added in v1.1.2
SetDialTimeout 设置超时时间
type EtcdDis ¶
type EtcdDis struct { Cluster string Etcd *Etcd //etcd服务集群机器 //注册; key:服务名称 MapRegister map[string]*EtcdService //["Cluster/server.name:Kind"]*EtcdService //监听相关的服务 MapWatch map[string]*EtcdMaster //[service_name]*EtcdService Logger *logrus.Logger sync.RWMutex }
func NewEtcdDis ¶
NewEtcdDis 注册相关的函数
func (*EtcdDis) GetGrpcServiceInfoRandom ¶ added in v1.1.0
GetGrpcServiceInfoRandom 获取服务grpc节点信息-随机获取
func (*EtcdDis) GetServiceInfoAllNode ¶
GetServiceInfoAllNode 获取服务的节点信息
type EtcdMaster ¶
type EtcdMaster struct { Cluster string Etcd *Etcd Service string //路径 Nodes map[string]*EtcdNode //[grpc]*EtcdNode State bool Loger *logrus.Logger sync.Mutex // contains filtered or unexported fields }
func (*EtcdMaster) Close ¶ added in v1.1.0
func (m *EtcdMaster) Close()
func (*EtcdMaster) DecodeKeyValue ¶ added in v1.1.0
func (*EtcdMaster) DoWatch ¶ added in v1.1.0
func (m *EtcdMaster) DoWatch()
func (*EtcdMaster) Get ¶ added in v1.1.0
func (m *EtcdMaster) Get()
func (*EtcdMaster) GetAllNodes ¶
func (m *EtcdMaster) GetAllNodes() []EtcdNode
func (*EtcdMaster) GetGrpcNodeRandom ¶ added in v1.1.0
func (m *EtcdMaster) GetGrpcNodeRandom() (*ValueInfo, bool)
func (*EtcdMaster) GetKeyInfo ¶
func (m *EtcdMaster) GetKeyInfo(key []byte) (*KeyInfo, error)
func (*EtcdMaster) GetPrefixPath ¶ added in v1.1.0
func (m *EtcdMaster) GetPrefixPath() string
func (*EtcdMaster) GetValueInfo ¶
func (m *EtcdMaster) GetValueInfo(value []byte) (*ValueInfo, error)
func (*EtcdMaster) NewEtcdNodes ¶ added in v1.1.0
func (m *EtcdMaster) NewEtcdNodes(state bool, keyInfo *KeyInfo) *EtcdNode
func (*EtcdMaster) ReBuildNode ¶ added in v1.1.0
func (m *EtcdMaster) ReBuildNode(keyInfo *KeyInfo)
func (*EtcdMaster) Stop ¶ added in v1.1.0
func (m *EtcdMaster) Stop()
func (*EtcdMaster) Watch ¶ added in v1.1.0
func (m *EtcdMaster) Watch()
type EtcdNode ¶
type EtcdNode struct { State bool *KeyInfo EndPoints map[string]*ValueInfo //[ip:port]ValueInfo sync.Mutex }
EtcdNode etcd注册的节点
func (*EtcdNode) GetEndPointRandom ¶ added in v1.1.0
type EtcdService ¶
type EtcdService struct { Key *KeyInfo Value *ValueInfo Retry bool // contains filtered or unexported fields }
func NewEtcdService ¶
func (*EtcdService) GetInfo ¶ added in v1.1.0
func (s *EtcdService) GetInfo() ([]*mvccpb.KeyValue, error)
func (*EtcdService) KeepLive ¶
func (s *EtcdService) KeepLive() (<-chan *clientv3.LeaseKeepAliveResponse, error)
KeepLive 用于维持租约
func (*EtcdService) ReStart ¶
func (s *EtcdService) ReStart() error
func (*EtcdService) UpdateService ¶
func (s *EtcdService) UpdateService(status STATUS, requestFlow uint32) error
type Hub ¶
type Hub struct { Etcd *Etcd // contains filtered or unexported fields }
func (*Hub) AddEtcdServerAddress ¶
AddEtcdServerAddress 添加etcd服务地址
func (*Hub) SetEtcdServerAddress ¶
SetEtcdServerAddress 设置etcd服务地址
type KeyInfo ¶
func NewKeyInfo ¶
func (*KeyInfo) GetNameKind ¶
func (*KeyInfo) GetRegisterKey ¶
func (*KeyInfo) SetRegisterKey ¶
SetRegisterKey 设置注册地址
type STATUS ¶
type STATUS int
STATUS 0 初始化, 1 正常服务, 2,挂起, 3, 主动关闭 500 异常情况
const StatusClose STATUS = 3
const StatusConnectError STATUS = 500
const StatusEtcdRemoteCloseError STATUS = 505
const StatusGrantError STATUS = 501
const StatusHang STATUS = 2
const StatusInit STATUS = 0
const StatusKeepaliveError STATUS = 503
const StatusOk STATUS = 1
const StatusPutError STATUS = 502
const StatusRevokeError STATUS = 504
type ValueInfo ¶
type ValueInfo struct { Kind string //grpc,http Ip string //服务注册ip Port uint32 //服务注册端口 Status STATUS //0 初始化, 1 正常 , 2 挂起, 3关闭 RequestFlow uint32 UpdatedAt int64 }
func NewValueInfo ¶
func (*ValueInfo) DecodeValue ¶
DecodeValue 解码 proto消息
func (*ValueInfo) EncodeValue ¶
EncodeValue 编码 proto消息
func (*ValueInfo) GetValidAddress ¶
func (*ValueInfo) SetRegisterAddress ¶
SetRegisterAddress 设置服务地址 ip:port
Click to show internal directories.
Click to hide internal directories.