Skip to content

Commit

Permalink
新增:队列增加休眠时间
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Mar 24, 2024
1 parent ca01c6e commit d042e20
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 2 additions & 1 deletion module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/farseer-go/fs/trace"
"github.com/farseer-go/queue"
"strings"
"time"
)

// Enable 是否启用
Expand Down Expand Up @@ -37,6 +38,6 @@ func (module Module) PreInitialize() {
if !strings.HasSuffix(FopsServer, "/") {
FopsServer += "/"
}
queue.Subscribe("TraceContext", "SaveTraceContext", 1000, SaveTraceContextConsumer)
queue.Subscribe("TraceContext", "SaveTraceContext", 1000,5*time.Second, SaveTraceContextConsumer)
}
}
3 changes: 0 additions & 3 deletions saveTraceContextConsumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ import (
"github.com/farseer-go/fs/parse"
"github.com/farseer-go/fs/trace"
"net/http"
"time"
)

// FopsServer fops地址
var FopsServer string

// SaveTraceContextConsumer 上传链路记录到FOPS中心
func SaveTraceContextConsumer(subscribeName string, lstMessage collections.ListAny, remainingCount int) {
// 控制3秒执行一次
<-time.After(3 * time.Second)
if traceContext := trace.CurTraceContext.Get(); traceContext != nil {
traceContext.Ignore()
}
Expand Down

0 comments on commit d042e20

Please sign in to comment.