Skip to content

Commit

Permalink
refactor(keeper): eliminate warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
qevolg committed Dec 3, 2024
1 parent c81bb88 commit da93df1
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 34 deletions.
6 changes: 1 addition & 5 deletions tools/keeper/api/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}) {
qid := util.GetQidOwn()

commonLogger := commonLogger.WithFields(
logrus.Fields{config.ReqIDKey: qid},
)
commonLogger := commonLogger.WithFields(logrus.Fields{config.ReqIDKey: qid})

ctx := context.Background()

Expand All @@ -43,7 +40,6 @@ func CreateDatabase(username string, password string, host string, port int, use
}
return
}
panic(err)
}

func generateCreateDBSql(dbname string, databaseOptions map[string]interface{}) string {
Expand Down
6 changes: 3 additions & 3 deletions tools/keeper/api/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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')",
ClusterID+strconv.Itoa(dnode.DnodeID), dnode.DnodeID, dnode.DnodeEp, ClusterID, ts, dnode.Status))
dtotal++
if "ready" == dnode.Status {
if dnode.Status == "ready" {
dalive++
}
}
Expand All @@ -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')",
ClusterID+strconv.Itoa(mnode.MnodeID), mnode.MnodeID, mnode.MnodeEp, ClusterID, ts, mnode.Role))
mtotal++
//LEADER FOLLOWER CANDIDATE ERROR
if "ERROR" != mnode.Role {
// LEADER FOLLOWER CANDIDATE ERROR
if mnode.Role != "ERROR" {
malive++
}
}
Expand Down
9 changes: 6 additions & 3 deletions tools/keeper/db/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

"github.com/sirupsen/logrus"
"github.com/taosdata/driver-go/v3/common"

_ "github.com/taosdata/driver-go/v3/taosRestful"
"github.com/taosdata/taoskeeper/infrastructure/config"
Expand Down Expand Up @@ -70,9 +69,13 @@ func NewConnectorWithDb(username, password, host string, port int, dbname string
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) {
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)
startTime := time.Now()
Expand Down Expand Up @@ -120,7 +123,7 @@ func logData(data *Data, logger *logrus.Entry) {

func (c *Connector) Query(ctx context.Context, sql string, qid uint64) (*Data, error) {
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)

Expand Down
8 changes: 0 additions & 8 deletions tools/keeper/infrastructure/log/empty_test.go

This file was deleted.

1 change: 0 additions & 1 deletion tools/keeper/infrastructure/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/sirupsen/logrus"
rotatelogs "github.com/taosdata/file-rotatelogs/v2"
"github.com/taosdata/taoskeeper/infrastructure/config"

"github.com/taosdata/taoskeeper/version"
)

Expand Down
8 changes: 0 additions & 8 deletions tools/keeper/monitor/empty_test.go

This file was deleted.

5 changes: 2 additions & 3 deletions tools/keeper/monitor/monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import (
"github.com/taosdata/go-utils/web"
"github.com/taosdata/taoskeeper/api"
"github.com/taosdata/taoskeeper/db"
"github.com/taosdata/taoskeeper/util"

"github.com/taosdata/taoskeeper/infrastructure/config"
"github.com/taosdata/taoskeeper/infrastructure/log"
"github.com/taosdata/taoskeeper/util"
)

func TestStart(t *testing.T) {
Expand All @@ -35,7 +34,7 @@ func TestStart(t *testing.T) {
conf.RotationInterval = "1s"
StartMonitor("", conf, reporter)
time.Sleep(2 * time.Second)
for k, _ := range SysMonitor.outputs {
for k := range SysMonitor.outputs {
SysMonitor.Deregister(k)
}

Expand Down
4 changes: 1 addition & 3 deletions tools/keeper/util/pool/antpool.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package pool

import (
"github.com/panjf2000/ants/v2"
)
import "github.com/panjf2000/ants/v2"

var GoroutinePool *ants.Pool

Expand Down

0 comments on commit da93df1

Please sign in to comment.