Commit f0dce6d6 by 孙龙

init

parent b548381f
package apiMsgService package apiMsgService
import ( import (
"fmt"
"go-api-behavior/util" "go-api-behavior/util"
"context"
//"fmt" //"fmt"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"context"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
"time" "time"
) )
...@@ -57,7 +56,7 @@ func (logSink *LogSink) writeLoop() { ...@@ -57,7 +56,7 @@ func (logSink *LogSink) writeLoop() {
for { for {
select { select {
case log = <- logSink.logChan: case log = <- logSink.logChan:
fmt.Println("新任务") //fmt.Println("新任务")
if logBatch == nil { if logBatch == nil {
logBatch = &LogBatch{} logBatch = &LogBatch{}
} }
...@@ -75,8 +74,8 @@ func (logSink *LogSink) writeLoop() { ...@@ -75,8 +74,8 @@ func (logSink *LogSink) writeLoop() {
if logBatch == nil { if logBatch == nil {
logBatch = &LogBatch{} logBatch = &LogBatch{}
} }
fmt.Println("超时到期了") //fmt.Println("超时到期了")
fmt.Println(len(logBatch.Logs)) //fmt.Println(len(logBatch.Logs))
logSink.saveLogs(logBatch) logSink.saveLogs(logBatch)
logBatch = nil logBatch = nil
t.Reset(time.Second * 20) t.Reset(time.Second * 20)
......
...@@ -17,7 +17,7 @@ type RecvPro struct { ...@@ -17,7 +17,7 @@ type RecvPro struct {
//// 实现消费者 消费消息失败 自动进入延时尝试 尝试3次之后入库db //// 实现消费者 消费消息失败 自动进入延时尝试 尝试3次之后入库db
func (t *RecvPro) Consumer(dataByte []byte) error { func (t *RecvPro) Consumer(dataByte []byte) error {
fmt.Println(string(dataByte)) //fmt.Println(string(dataByte))
err := apiMsgService.SaveMsgToLogChan(string(dataByte)) err := apiMsgService.SaveMsgToLogChan(string(dataByte))
if err != nil{ if err != nil{
logger.Error("%s",err) logger.Error("%s",err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment