Documentation ¶
Index ¶
- func Close()
- func GetDb() *gorm.DB
- type Etcd
- func (etcd *Etcd) GetByKey(etcdKey string, opts ...clientv3.OpOption) (getResponse *clientv3.GetResponse, err error)
- func (etcd *Etcd) NewEtcdLock(name string, duration int64) (etcdLock *datamodels.EtcdLock, err error)
- func (etcd *Etcd) PutKeyValue(etcdKey string, etcdValue string, opts ...clientv3.OpOption) (putResponse *clientv3.PutResponse, err error)
- func (etcd *Etcd) WatchKeys(keyDir string, watchHandler interfaces.WatchHandler) (err error)
- type MongoDB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Etcd ¶
type Etcd struct { Client *clientv3.Client KV clientv3.KV Lease clientv3.Lease Watcher clientv3.Watcher }
etcd对象
func (*Etcd) GetByKey ¶
func (etcd *Etcd) GetByKey(etcdKey string, opts ...clientv3.OpOption) (getResponse *clientv3.GetResponse, err error)
从etcd中获取数据
func (*Etcd) NewEtcdLock ¶
func (etcd *Etcd) NewEtcdLock(name string, duration int64) (etcdLock *datamodels.EtcdLock, err error)
实例化一个etcdLock
func (*Etcd) PutKeyValue ¶
func (etcd *Etcd) PutKeyValue(etcdKey string, etcdValue string, opts ...clientv3.OpOption) (putResponse *clientv3.PutResponse, err error)
创建Key
func (*Etcd) WatchKeys ¶
func (etcd *Etcd) WatchKeys(keyDir string, watchHandler interfaces.WatchHandler) (err error)
Watch keys 监听etcd key的变化: 比如监听jobs的变化,和监听kill的任务 传递的参数:要监听的key的前缀,和处理监听的接口 keyDir: eg: /crontab/jobs/ 监听前缀是jobs的key watchHandler:接口
- HandlerGetResponse: 获取这些前缀的keyValue,然后做相应的处理
- HandlerWatchChan:处理watchChan,比如修改了某个key,就有个WatchResponse推送到watchChan中
Click to show internal directories.
Click to hide internal directories.