Run stat report loop
()
| 135 | |
| 136 | // Run stat report loop |
| 137 | func (s *StatFHelper) Run() { |
| 138 | ticker := time.NewTicker(s.app.ServerConfig().StatReportInterval) |
| 139 | for { |
| 140 | select { |
| 141 | case stStatInfo := <-s.chStatInfo: |
| 142 | s.collectMsg(stStatInfo, s.mStatInfo, s.mStatCount) |
| 143 | case stStatInfoFromServer := <-s.chStatInfoFromServer: |
| 144 | s.collectMsg(stStatInfoFromServer, s.mStatInfoFromServer, s.mStatCountFromServer) |
| 145 | case <-ticker.C: |
| 146 | if len(s.mStatInfo) > 0 { |
| 147 | s.reportAndClear("mStatInfo", true) |
| 148 | } |
| 149 | if len(s.mStatInfoFromServer) > 0 { |
| 150 | s.reportAndClear("mStatInfoFromServer", false) |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | func (s *StatFHelper) pushBackMsg(stStatInfo StatInfo, fromServer bool) { |
| 157 | if fromServer { |