Documentation ¶
Index ¶
- Constants
- Variables
- func InstallExt(ctrlName string, mc IMCGeter, conf *clientv3.Config)
- func NewLocker(name string, custCli ...*clientv3.Client) (sync.Locker, error)
- func PreUnload(name string) error
- type EWatchEvent
- type Etcd
- func (this *Etcd) Client() *clientv3.Client
- func (this *Etcd) Content(name string) string
- func (this *Etcd) Count() int
- func (this *Etcd) Del(key string) error
- func (this *Etcd) DelRange(prefixKey string) error
- func (this *Etcd) Get(key string, rev ...int64) ([]byte, error)
- func (this *Etcd) GetRange(key string, opt ...*GetOpt) (keys []string, values [][]byte, err error)
- func (this *Etcd) HandleInit()
- func (this *Etcd) HandleTerm()
- func (this *Etcd) HasUnit(name string) int
- func (this *Etcd) LeaseKeepalive(key, value string, ttl time.Duration) (context.CancelFunc, error)
- func (this *Etcd) Load(name string, storer IStorer) error
- func (this *Etcd) Mount(source TUnits)
- func (this *Etcd) NewMutex(name, prefixKey string) (sync.Locker, error)
- func (this *Etcd) Overview() string
- func (this *Etcd) Set(key, value string, ttl ...time.Duration) error
- func (this *Etcd) Setnx(key, value string) (success bool, oldValue []byte, err error)
- func (this *Etcd) Setox(key, value, oldValue string) (bool, error)
- func (this *Etcd) Watch(key string, callBack func(e EWatchEvent, val []byte))
- func (this *Etcd) WatchPrefix(prefixKey string, callBack func(e EWatchEvent, key, val []byte))
- type GetOpt
- type IMCGeter
- type IStorer
- type Key
- func (k Key) Del() error
- func (k Key) DelRange() error
- func (k Key) Empty() bool
- func (k Key) Get(rev ...int64) ([]byte, error)
- func (k Key) GetRange(opt ...*GetOpt) (keys []string, values [][]byte, err error)
- func (k Key) LeaseKeepalive(val string, ttl time.Duration) error
- func (k Key) Set(val string, ttl ...time.Duration) error
- func (k Key) Setnx(val string) (success bool, oldValue []byte, err error)
- func (k Key) Setox(val, oldValue string) (bool, error)
- func (k Key) StopLease(del ...bool)
- func (k Key) Valid() bool
- func (k Key) Watch(callBack func(e EWatchEvent, val []byte))
- func (k Key) WatchPrefix(callBack func(e EWatchEvent, key, val []byte))
- type TUnits
- type Unit
Constants ¶
View Source
const ( DEF_UNIT_MSIZE = 10 DEF_DIAL_TIMEOUT = 3 * time.Second // 默认连接超时时间 DEF_OPT_TIMEOUT = 3 * time.Second // 默认操作超时时间 )
Variables ¶
View Source
var (
ErrUnwantReload = errors.New("ErrUnwantReload") // 不需要热加载可以返回此error
)
Functions ¶
Types ¶
type EWatchEvent ¶
type EWatchEvent int //
=> 监听事件类型
const ( EWatch_Create EWatchEvent = iota + 1 // 创建 EWatch_Update // 更新 EWatch_Delete // 删除 )
type Etcd ¶
type Etcd struct { cto.ControlBase // contains filtered or unexported fields }
=> etcd client control
func (*Etcd) HandleInit ¶
func (this *Etcd) HandleInit()
func (*Etcd) HandleTerm ¶
func (this *Etcd) HandleTerm()
func (*Etcd) LeaseKeepalive ¶
Etcd.LeaseKeepalive Lease the key will be kept forever
func (*Etcd) Watch ¶
func (this *Etcd) Watch(key string, callBack func(e EWatchEvent, val []byte))
Etcd.Watch Watch a key
func (*Etcd) WatchPrefix ¶
func (this *Etcd) WatchPrefix(prefixKey string, callBack func(e EWatchEvent, key, val []byte))
Etcd.WatchPrefix with prefix key
type GetOpt ¶
type GetOpt struct { Prefix bool // Keys with matching prefix. RangeEndKey string // Returns the keys in the range [key, end) FromKey bool // to be equal or greater than they key in the argument Limit int64 // limits the number of results to return Rev int64 // Specifies the store revision SortOrder int // specifies the ordering, see etcd.SortOrder SortTarget int // specifies the ordering, see etcd.SortTarget FirstKey, LastKey bool // gets the lexically first/last key in the request range. }
type IMCGeter ¶
type IMCGeter interface { cto.ICtrlHandler // 获取基类配置 HandleEtcd() *Etcd }
=> ETCD 对象接口
type IStorer ¶
type IStorer interface { // 配置名称 HandleKey() string // 配置加载 HandleInit(val []byte) error // 配置内容 HandleContent() string // 配置热加载[自行保证线程安全,当不需要热加载时可以返回 ErrUnwantReload] HandleReload(e EWatchEvent, val []byte) error }
=> 配置数据接口
type Key ¶
type Key struct { KEY string // Key的路径 // contains filtered or unexported fields }
func (Key) LeaseKeepalive ¶
Key.LeaseKeepalive Set value and Lease the key will be kept forever
func (Key) Watch ¶
func (k Key) Watch(callBack func(e EWatchEvent, val []byte))
Key.Watch Watch a key
func (Key) WatchPrefix ¶
func (k Key) WatchPrefix(callBack func(e EWatchEvent, key, val []byte))
Key.WatchPrefix with prefix key
Click to show internal directories.
Click to hide internal directories.