Documentation ¶
Index ¶
- Constants
- Variables
- type ChangeHandler
- type ClientX
- func (c *ClientX) Delete(ctx context.Context, key string) error
- func (c *ClientX) DialGrpc(service string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func (c *ClientX) Get(ctx context.Context, key string) ([]byte, error)
- func (c *ClientX) GetWithPrefix(ctx context.Context, key string) ([][]byte, error)
- func (c *ClientX) Put(ctx context.Context, key, value string) error
- func (c *ClientX) Watch(ctx context.Context, key string, putHandler ChangeHandler, ...)
- func (c *ClientX) WatchWithPrefix(ctx context.Context, key string, putHandler ChangeHandler, ...)
- type MetaData
- type ServiceManager
- func (s *ServiceManager) Destory(addr string) error
- func (s *ServiceManager) List() (map[string]endpoints.Endpoint, error)
- func (s *ServiceManager) PushEndpoint(addr string, metadata interface{}) error
- func (s *ServiceManager) Register(addr string, metadate ...interface{}) error
- func (s *ServiceManager) Watch(h func(key string, ep endpoints.Endpoint)) error
Constants ¶
View Source
const ( // DefaultDialTimout 默认连接超时时间 DefaultDialTimout = 10 * time.Second )
Variables ¶
View Source
var ( // DefaultMetaData 默认元数据 DefaultMetaData = &MetaData{ Network: "http", } )
View Source
var ErrorNotFound = errors.New("not found")
ErrorNotFound 表示该key找不多对应的值,即不存在
Functions ¶
This section is empty.
Types ¶
type ClientX ¶
type ClientX struct {
// contains filtered or unexported fields
}
ClientX 是封装的Etcd客户端操作
func (*ClientX) DialGrpc ¶
func (c *ClientX) DialGrpc(service string, opts ...grpc.DialOption) (*grpc.ClientConn, error)
DialGrpc 使用gRpc的负载均很获取grpc连接
func (*ClientX) GetWithPrefix ¶
GetWithPrefix 前缀获取一组键值,找不到 ErrorNotFound
func (*ClientX) Watch ¶
func (c *ClientX) Watch(ctx context.Context, key string, putHandler ChangeHandler, delHandler ChangeHandler)
Watch 监听指定键的变化
func (*ClientX) WatchWithPrefix ¶
func (c *ClientX) WatchWithPrefix(ctx context.Context, key string, putHandler ChangeHandler, delHandler ChangeHandler)
WatchWithPrefix 监听某一组简直对的变化
type ServiceManager ¶
type ServiceManager struct {
// contains filtered or unexported fields
}
ServiceManager 服务节点管理器
func NewServiceManager ¶
func NewServiceManager(xClient *ClientX, target string, leaseTTl int64, heartT int) (*ServiceManager, error)
NewServiceManager 增加服务节点管理器
func (*ServiceManager) List ¶ added in v0.1.3
func (s *ServiceManager) List() (map[string]endpoints.Endpoint, error)
List 获取当前target的所有节点
func (*ServiceManager) PushEndpoint ¶ added in v0.1.2
func (s *ServiceManager) PushEndpoint(addr string, metadata interface{}) error
PushEndpoint push节点数据
func (*ServiceManager) Register ¶
func (s *ServiceManager) Register(addr string, metadate ...interface{}) error
Register 注册到节点
Click to show internal directories.
Click to hide internal directories.