refactor(keeper): modify log and optimize code

This commit is contained in:
qevolg 2025-01-06 22:35:08 +08:00
parent bea62b713b
commit 57e48a5ae6
3 changed files with 9 additions and 13 deletions

View File

@ -332,7 +332,7 @@ func (r *Reporter) handlerFunc() gin.HandlerFunc {
logger.Tracef("report data:%s", string(data))
if e := json.Unmarshal(data, &report); e != nil {
logger.Errorf("error occurred while unmarshal request, data:%s, error:%s", data, err)
logger.Errorf("error occurred while unmarshal request, data:%s, error:%v", data, e)
return
}
var sqls []string

View File

@ -58,7 +58,7 @@ func NewCommand(conf *config.Config) *Command {
panic(err)
}
imp := &Command{
return &Command{
client: client,
conn: conn,
username: conf.TDengine.Username,
@ -70,7 +70,6 @@ func NewCommand(conf *config.Config) *Command {
RawQuery: fmt.Sprintf("db=%s&precision=ms", conf.Metrics.Database.Name),
},
}
return imp
}
func (cmd *Command) Process(conf *config.Config) {
@ -101,7 +100,7 @@ func (cmd *Command) Process(conf *config.Config) {
}
func (cmd *Command) ProcessTransfer(conf *config.Config) {
fromTime, err := time.Parse("2006-01-02T15:04:05Z07:00", conf.FromTime)
fromTime, err := time.Parse(time.RFC3339, conf.FromTime)
if err != nil {
logger.Errorf("parse fromTime error, msg:%s", err)
return
@ -401,7 +400,6 @@ func (cmd *Command) TransferTaosdClusterBasicInfo() error {
// cluster_info
func (cmd *Command) TransferTableToDst(sql string, dstTable string, tagNum int) error {
ctx := context.Background()
endTime := time.Now()

View File

@ -41,33 +41,31 @@ func (s *sysMonitor) collect() {
}
s.Lock()
defer s.Unlock()
for output := range s.outputs {
select {
case output <- *s.status:
default:
}
}
s.Unlock()
}
func (s *sysMonitor) Register(c chan<- SysStatus) {
s.Lock()
defer s.Unlock()
if s.outputs == nil {
s.outputs = map[chan<- SysStatus]struct{}{
c: {},
s.outputs = map[chan<- SysStatus]struct{}{}
}
} else {
s.outputs[c] = struct{}{}
}
s.Unlock()
}
func (s *sysMonitor) Deregister(c chan<- SysStatus) {
s.Lock()
defer s.Unlock()
if s.outputs != nil {
delete(s.outputs, c)
}
s.Unlock()
}
var SysMonitor = &sysMonitor{status: &SysStatus{}}