3 Star 3 Fork 1

Gitee 极速下载 / mymon

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/open-falcon/mymon
克隆/下载
mysql.go 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
/*
* Open-Falcon
*
* Copyright (c) 2014-2018 Xiaomi, Inc. All Rights Reserved.
*
* This product is licensed to you under the Apache License, Version 2.0 (the "License").
* You may not use this product except in compliance with the License.
*
* This product may include a number of subcomponents with separate copyright notices
* and license terms. Your use of these subcomponents is subject to the terms and
* conditions of the subcomponent's license, as noted in the LICENSE file.
*/
package common
import (
"fmt"
"time"
"github.com/pkg/errors"
"github.com/ziutek/mymysql/mysql"
_ "github.com/ziutek/mymysql/native" //with mysql
)
// NewMySQLConnection the constructor of mysql connecting
func NewMySQLConnection(conf *Config) (mysql.Conn, error) {
return initMySQLConnection(conf)
}
// QueryResult the result of query
func initMySQLConnection(conf *Config) (db mysql.Conn, err error) {
db = mysql.New("tcp", "", fmt.Sprintf(
"%s:%d", conf.DataBase.Host, conf.DataBase.Port),
conf.DataBase.User, conf.DataBase.Password)
db.SetTimeout(500 * time.Millisecond)
if err = db.Connect(); err != nil {
err = errors.Wrap(err, "Building mysql connection failed!")
}
return
}
Shell
1
https://gitee.com/mirrors/mymon.git
git@gitee.com:mirrors/mymon.git
mirrors
mymon
mymon
fda4d97c10d2

搜索帮助

53164aa7 5694891 3bd8fe86 5694891