Documentation ¶
Index ¶
- Constants
- Variables
- func IsNotFoundErr(err error) bool
- type Client
- func (c *Client) Close() error
- func (c *Client) Create(ctx context.Context, nodePath string, content []byte) WRet
- func (c *Client) Delete(ctx context.Context, nodePath string, revision int64) WRet
- func (c *Client) DeleteDir(ctx context.Context, nodePath string, revision int64) WRet
- func (c *Client) Get(ctx context.Context, nodePath string, opts ...clientv3.OpOption) NodeRet
- func (c *Client) GetDir(ctx context.Context, nodePath string, keyOnly bool) DirRet
- func (c *Client) Put(ctx context.Context, nodePath string, content []byte, revision int64) WRet
- func (c *Client) WatchDir(ctx context.Context, nodePath string, timeout time.Duration, ignoreEmpty bool) (DirRet, <-chan DirEvent, context.CancelFunc)
- type Code
- type DirEvent
- type DirRet
- type Error
- type NodeRet
- type Option
- type WRet
- type Watcher
Constants ¶
const ( //DefaultDialTimeout default dial timeout DefaultDialTimeout = 3 * time.Second //IgnoreRevision use -1 as ignore revision check IgnoreRevision = -1 )
const (
//ChanBufferSize chan buffer size
ChanBufferSize = 10
)
Variables ¶
var ( //ErrEmptyRoot root path empty is dangerous ErrEmptyRoot = errors.New("etcd.root.path.empty") //ErrInvalidPath invalid path ErrInvalidPath = errors.New("invalid.etcd.path") )
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client etcd client
func (*Client) GetDir ¶
GetDir common get dir get dir - if keyOnly is false, get all dir children data.
func (*Client) WatchDir ¶
func (c *Client) WatchDir(ctx context.Context, nodePath string, timeout time.Duration, ignoreEmpty bool) (DirRet, <-chan DirEvent, context.CancelFunc)
WatchDir watch dir ctx -- cancel controller, it's a parent context for watch nodePath -- path timeout -- get dir timeout ignoreEmpty -- if ignore, even get nothing from dir, watch still continue to work return first get dir content/dir watch event/current watch session cancel
type Code ¶
type Code int
Code error code
const ( OK Code = iota Unavailable //Timeout rpc timeout Timeout //Cancelled rpc cancelled Cancelled //NodeExist node not exist NodeExist //NodeNotFound node not found NodeNotFound //BadVersion bad version check BadVersion //BadRsp bad response BadRsp //WatchFail watch fail WatchFail //WatchUnexpected watch unexpected event WatchUnexpected //WatchClosed watch closed WatchClosed //Unknown unknown error Unknown )
type DirRet ¶
DirRet Read Dir Ret
func (*DirRet) ExceptNotFoundErr ¶
ExceptNotFoundErr dir ret is error except "not found"
type Option ¶
type Option func(*_Option)
Option setup option
func WithDialTimeout ¶
WithDialTimeout set dial timeout
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
func NewWatcher ¶
NewWatcher new watcher
func (*Watcher) StartWatchDir ¶
func (w *Watcher) StartWatchDir()
StartWatchDir loop watch dir -- if chan closed, which means go routine out
func (*Watcher) StartWatchDirWhenExist ¶
func (w *Watcher) StartWatchDirWhenExist()
StartWatchDirWhenExist loop watch dir -- if chan closed, which means go routine out only in case there is any key under the watch path