Skip to content

Commit

Permalink
fix keepalive log will increase over time
Browse files Browse the repository at this point in the history
fix #68
  • Loading branch information
zyxkad committed May 26, 2024
1 parent a557195 commit b78a80c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,11 @@ func (cr *Cluster) KeepAlive(ctx context.Context) (status int) {
hits, hbts := cr.stats.GetTmpHits()
lhits, lhbts := cr.lastHits.Load(), cr.lastHbts.Load()
hits2, hbts2 := cr.statOnlyHits.Load(), cr.statOnlyHbts.Load()
ahits, ahbts := hits - lhits - hits2, hbts - lhbts - hbts2
resCh, err := cr.socket.EmitWithAck("keep-alive", Map{
"time": time.Now().UTC().Format("2006-01-02T15:04:05Z"),
"hits": hits - lhits - hits2,
"bytes": hbts - lhbts - hbts2,
"hits": ahits,
"bytes": ahbts,
})
go cr.notifyManager.OnReportStatus(&cr.stats)

Expand Down Expand Up @@ -617,7 +618,7 @@ func (cr *Cluster) KeepAlive(ctx context.Context) (status int) {
log.Errorf(Tr("error.cluster.keepalive.failed"), ero)
return 1
}
log.Infof(Tr("info.cluster.keepalive.success"), hits, utils.BytesToUnit((float64)(hbts)), data[1])
log.Infof(Tr("info.cluster.keepalive.success"), ahits, utils.BytesToUnit((float64)(ahbts)), data[1])
cr.lastHits.Store(hits)
cr.lastHbts.Store(hbts)
cr.statOnlyHits.Add(-hits2)
Expand Down

0 comments on commit b78a80c

Please sign in to comment.