Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Close()
- func (c *Client) DelKey(ctx context.Context, name string) error
- func (c *Client) GetLeaseTTL(ctx context.Context, leaseId int64) (int, error)
- func (c *Client) GetNode(ctx context.Context, name string) (Node, error)
- func (c *Client) GrantLease(ctx context.Context, ttl int) (int64, error)
- func (c *Client) Init() error
- func (c *Client) IsClosing() bool
- func (c *Client) IsNodeExist(ctx context.Context, name string) (bool, error)
- func (c *Client) KeepAlive(ctx context.Context, stopChan chan struct{}, leaseId int64) error
- func (c *Client) ListDir(ctx context.Context, dir string) ([]Node, error)
- func (c *Client) PutNode(ctx context.Context, name string, value interface{}, leaseId int64) error
- func (c *Client) RegisterAndKeepAliveForever(ctx context.Context, name string, value interface{}, ttl int) (*NodeKeepAliveContext, error)
- func (c *Client) RegisterNode(rootCtx context.Context, name string, value interface{}, ttl int) (int64, error)
- func (c *Client) RevokeKeepAlive(ctx context.Context, regCtx *NodeKeepAliveContext) error
- func (c *Client) RevokeLease(ctx context.Context, leaseId int64) error
- func (c *Client) SetVerbose(v int32)
- func (c *Client) WatchDir(ctx context.Context, dir string) <-chan *NodeEvent
- func (c *Client) WatchDirTo(ctx context.Context, dir string, nodeMap *NodeMap)
- type INode
- type Node
- type NodeEvent
- type NodeEventType
- type NodeKeepAliveContext
- type NodeMap
- func (m *NodeMap) Clear()
- func (m *NodeMap) Count() int
- func (m *NodeMap) DeleteNode(nodeType string, id uint16)
- func (m *NodeMap) DeleteNodes(nodeType string)
- func (m *NodeMap) GetKeys() []string
- func (m *NodeMap) GetNodes(nodeType string) NodeSet
- func (m *NodeMap) InsertNode(node Node)
- func (m *NodeMap) String() string
- type NodeSet
Constants ¶
View Source
const ( EventChanCapacity = 1000 OpTimeout = 3 VerboseLv1 = 1 VerboseLv2 = 2 )
View Source
const ( NODE_KEY_ID = "ID" NODE_KEY_TYPE = "Type" NODE_KEY_INTERFACE = "Interface" NODE_KEY_PID = "PID" NODE_KEY_HOST = "Host" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
基于etcd的服务发现
func (*Client) GetLeaseTTL ¶
func (*Client) GrantLease ¶
申请一个lease
func (*Client) IsNodeExist ¶
节点是否存在
func (*Client) RegisterAndKeepAliveForever ¶
func (c *Client) RegisterAndKeepAliveForever(ctx context.Context, name string, value interface{}, ttl int) (*NodeKeepAliveContext, error)
注册一个节点,并永久保活
func (*Client) RegisterNode ¶
func (c *Client) RegisterNode(rootCtx context.Context, name string, value interface{}, ttl int) (int64, error)
注册一个节点信息,并返回一个ttl秒的lease
func (*Client) RevokeKeepAlive ¶ added in v0.1.4
func (c *Client) RevokeKeepAlive(ctx context.Context, regCtx *NodeKeepAliveContext) error
func (*Client) RevokeLease ¶
撤销一个lease
func (*Client) SetVerbose ¶
type NodeEventType ¶
type NodeEventType int
const ( EventUnknown NodeEventType = 0 EventCreate NodeEventType = 1 EventUpdate NodeEventType = 2 EventDelete NodeEventType = 3 )
func (NodeEventType) String ¶
func (e NodeEventType) String() string
type NodeKeepAliveContext ¶ added in v0.1.4
type NodeKeepAliveContext struct { LeaseId int64 LeaseAlive bool Name string Value interface{} TTL int // contains filtered or unexported fields }
用于注册并保活节点
func NewNodeKeepAliveContext ¶ added in v0.1.4
func NewNodeKeepAliveContext(name string, value interface{}, ttl int) *NodeKeepAliveContext
type NodeMap ¶
type NodeMap struct {
// contains filtered or unexported fields
}
按服务类型区分的节点信息
func NewNodeMap ¶
func NewNodeMap() *NodeMap
Click to show internal directories.
Click to hide internal directories.