refactor(keeper): eliminate warnings
This commit is contained in:
parent
c81bb880f0
commit
da93df104e
|
@ -17,10 +17,7 @@ var commonLogger = log.GetLogger("CMN")
|
||||||
|
|
||||||
func CreateDatabase(username string, password string, host string, port int, usessl bool, dbname string, databaseOptions map[string]interface{}) {
|
func CreateDatabase(username string, password string, host string, port int, usessl bool, dbname string, databaseOptions map[string]interface{}) {
|
||||||
qid := util.GetQidOwn()
|
qid := util.GetQidOwn()
|
||||||
|
commonLogger := commonLogger.WithFields(logrus.Fields{config.ReqIDKey: qid})
|
||||||
commonLogger := commonLogger.WithFields(
|
|
||||||
logrus.Fields{config.ReqIDKey: qid},
|
|
||||||
)
|
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
@ -43,7 +40,6 @@ func CreateDatabase(username string, password string, host string, port int, use
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
panic(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateCreateDBSql(dbname string, databaseOptions map[string]interface{}) string {
|
func generateCreateDBSql(dbname string, databaseOptions map[string]interface{}) string {
|
||||||
|
|
|
@ -384,7 +384,7 @@ func insertClusterInfoSql(info ClusterInfo, ClusterID string, protocol int, ts s
|
||||||
sqls = append(sqls, fmt.Sprintf("insert into d_info_%s using d_info tags (%d, '%s', '%s') values ('%s', '%s')",
|
sqls = append(sqls, fmt.Sprintf("insert into d_info_%s using d_info tags (%d, '%s', '%s') values ('%s', '%s')",
|
||||||
ClusterID+strconv.Itoa(dnode.DnodeID), dnode.DnodeID, dnode.DnodeEp, ClusterID, ts, dnode.Status))
|
ClusterID+strconv.Itoa(dnode.DnodeID), dnode.DnodeID, dnode.DnodeEp, ClusterID, ts, dnode.Status))
|
||||||
dtotal++
|
dtotal++
|
||||||
if "ready" == dnode.Status {
|
if dnode.Status == "ready" {
|
||||||
dalive++
|
dalive++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,8 +393,8 @@ func insertClusterInfoSql(info ClusterInfo, ClusterID string, protocol int, ts s
|
||||||
sqls = append(sqls, fmt.Sprintf("insert into m_info_%s using m_info tags (%d, '%s', '%s') values ('%s', '%s')",
|
sqls = append(sqls, fmt.Sprintf("insert into m_info_%s using m_info tags (%d, '%s', '%s') values ('%s', '%s')",
|
||||||
ClusterID+strconv.Itoa(mnode.MnodeID), mnode.MnodeID, mnode.MnodeEp, ClusterID, ts, mnode.Role))
|
ClusterID+strconv.Itoa(mnode.MnodeID), mnode.MnodeID, mnode.MnodeEp, ClusterID, ts, mnode.Role))
|
||||||
mtotal++
|
mtotal++
|
||||||
//LEADER FOLLOWER CANDIDATE ERROR
|
// LEADER FOLLOWER CANDIDATE ERROR
|
||||||
if "ERROR" != mnode.Role {
|
if mnode.Role != "ERROR" {
|
||||||
malive++
|
malive++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/taosdata/driver-go/v3/common"
|
|
||||||
|
|
||||||
_ "github.com/taosdata/driver-go/v3/taosRestful"
|
_ "github.com/taosdata/driver-go/v3/taosRestful"
|
||||||
"github.com/taosdata/taoskeeper/infrastructure/config"
|
"github.com/taosdata/taoskeeper/infrastructure/config"
|
||||||
|
@ -70,9 +69,13 @@ func NewConnectorWithDb(username, password, host string, port int, dbname string
|
||||||
return &Connector{db: db}, nil
|
return &Connector{db: db}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ReqIDKeyTy string
|
||||||
|
|
||||||
|
const ReqIDKey ReqIDKeyTy = "taos_req_id"
|
||||||
|
|
||||||
func (c *Connector) Exec(ctx context.Context, sql string, qid uint64) (int64, error) {
|
func (c *Connector) Exec(ctx context.Context, sql string, qid uint64) (int64, error) {
|
||||||
dbLogger := dbLogger.WithFields(logrus.Fields{config.ReqIDKey: qid})
|
dbLogger := dbLogger.WithFields(logrus.Fields{config.ReqIDKey: qid})
|
||||||
ctx = context.WithValue(ctx, common.ReqIDKey, int64(qid))
|
ctx = context.WithValue(ctx, ReqIDKey, int64(qid))
|
||||||
|
|
||||||
dbLogger.Tracef("call adapter to execute sql:%s", sql)
|
dbLogger.Tracef("call adapter to execute sql:%s", sql)
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
@ -120,7 +123,7 @@ func logData(data *Data, logger *logrus.Entry) {
|
||||||
|
|
||||||
func (c *Connector) Query(ctx context.Context, sql string, qid uint64) (*Data, error) {
|
func (c *Connector) Query(ctx context.Context, sql string, qid uint64) (*Data, error) {
|
||||||
dbLogger := dbLogger.WithFields(logrus.Fields{config.ReqIDKey: qid})
|
dbLogger := dbLogger.WithFields(logrus.Fields{config.ReqIDKey: qid})
|
||||||
ctx = context.WithValue(ctx, common.ReqIDKey, int64(qid))
|
ctx = context.WithValue(ctx, ReqIDKey, int64(qid))
|
||||||
|
|
||||||
dbLogger.Tracef("call adapter to execute query, sql:%s", sql)
|
dbLogger.Tracef("call adapter to execute query, sql:%s", sql)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
package log
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestEmpty(t *testing.T) {
|
|
||||||
}
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
rotatelogs "github.com/taosdata/file-rotatelogs/v2"
|
rotatelogs "github.com/taosdata/file-rotatelogs/v2"
|
||||||
"github.com/taosdata/taoskeeper/infrastructure/config"
|
"github.com/taosdata/taoskeeper/infrastructure/config"
|
||||||
|
|
||||||
"github.com/taosdata/taoskeeper/version"
|
"github.com/taosdata/taoskeeper/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
package monitor
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestEmpty(t *testing.T) {
|
|
||||||
}
|
|
|
@ -11,10 +11,9 @@ import (
|
||||||
"github.com/taosdata/go-utils/web"
|
"github.com/taosdata/go-utils/web"
|
||||||
"github.com/taosdata/taoskeeper/api"
|
"github.com/taosdata/taoskeeper/api"
|
||||||
"github.com/taosdata/taoskeeper/db"
|
"github.com/taosdata/taoskeeper/db"
|
||||||
"github.com/taosdata/taoskeeper/util"
|
|
||||||
|
|
||||||
"github.com/taosdata/taoskeeper/infrastructure/config"
|
"github.com/taosdata/taoskeeper/infrastructure/config"
|
||||||
"github.com/taosdata/taoskeeper/infrastructure/log"
|
"github.com/taosdata/taoskeeper/infrastructure/log"
|
||||||
|
"github.com/taosdata/taoskeeper/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStart(t *testing.T) {
|
func TestStart(t *testing.T) {
|
||||||
|
@ -35,7 +34,7 @@ func TestStart(t *testing.T) {
|
||||||
conf.RotationInterval = "1s"
|
conf.RotationInterval = "1s"
|
||||||
StartMonitor("", conf, reporter)
|
StartMonitor("", conf, reporter)
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
for k, _ := range SysMonitor.outputs {
|
for k := range SysMonitor.outputs {
|
||||||
SysMonitor.Deregister(k)
|
SysMonitor.Deregister(k)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package pool
|
package pool
|
||||||
|
|
||||||
import (
|
import "github.com/panjf2000/ants/v2"
|
||||||
"github.com/panjf2000/ants/v2"
|
|
||||||
)
|
|
||||||
|
|
||||||
var GoroutinePool *ants.Pool
|
var GoroutinePool *ants.Pool
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue