datasources

package
v0.0.0-...-3f08e25 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

func GetDb

func GetDb() *gorm.DB

Types

type Etcd

type Etcd struct {
	Client  *clientv3.Client
	KV      clientv3.KV
	Lease   clientv3.Lease
	Watcher clientv3.Watcher
}

etcd对象

func GetEtcd

func GetEtcd() *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:接口

  1. HandlerGetResponse: 获取这些前缀的keyValue,然后做相应的处理
  2. HandlerWatchChan:处理watchChan,比如修改了某个key,就有个WatchResponse推送到watchChan中

type MongoDB

type MongoDB struct {
	Client     *mongo.Client
	Database   *mongo.Database
	Collection *mongo.Collection
}

func GetMongoDB

func GetMongoDB() *MongoDB

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL