Documentation ¶
Index ¶
- Constants
- Variables
- func DbSurvive(db *gorm.DB) error
- func GetDB(c *gin.Context, dbNmae ...string) *gorm.DB
- func InitDB(dsn string, dsn1 ...string) (db *gorm.DB, err error)
- func InitEsClient(addr, username, password string) (db *elastic.Client, err error)
- func InitKafkaConsumer(dsn, username, password string) (db *sarama.Consumer, err error)
- func InitKafkaProducer(dsn, username, password string) (db *sarama.SyncProducer, err error)
- func InitMongoDb(dns string, maxsize, timeOut int) (db *mongo.Client, err error)
- func InitRdb(addr, password string, num int) (db *redis.Client, err error)
- func Initialize(db *gorm.DB) (err error)
- func RdbSurvive(db *redis.Client) error
- type DbPoolCfg
Constants ¶
View Source
const ( LevelInfo = "info" LevelWarn = "warn" LevelError = "error" )
Variables ¶
View Source
var DB *gorm.DB
Functions ¶
func InitDB ¶
InitDB init db dsn string 示例 "账号:密码@tcp(服务器IP:端口)/数据库名?charset=utf8&parseTime=True&loc=Local" dsn1 支持多个,后面为从库
func InitEsClient ¶
InitEsClient ES初始化 dsn string http://127.0.0.1:9200 username 账号 可传空 password 密码
func InitKafkaConsumer ¶
*InitKafkaConsumer 获取消费端 dsn string localhost:9093 username 账号 可传空 password 密码
func InitKafkaProducer ¶
func InitKafkaProducer(dsn, username, password string) (db *sarama.SyncProducer, err error)
* InitKafkaProducer 获取kafka生产端 dsn string localhost:9093 username 账号 可传空 password 密码
func InitMongoDb ¶
InitMongoDb mongodb 初始化 dns string 示例 "mongodb://root:123456@127.0.0.1:27627" maxsize 连接池空闲连接数量 timeOut 空闲时间
func Initialize ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.