优化
This commit is contained in:
parent
9e7b2a1673
commit
324bea4b23
@ -15,6 +15,7 @@ import (
|
|||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -232,7 +233,7 @@ func InitDebugSarama() (fn func(), err error) {
|
|||||||
|
|
||||||
func RefreshTableId() (fn func(), err error) {
|
func RefreshTableId() (fn func(), err error) {
|
||||||
fn = func() {
|
fn = func() {
|
||||||
go report.RefreshTableIdMap()
|
go report.RefreshTableIdMap(5*time.Minute)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ type ReportService struct {
|
|||||||
|
|
||||||
var tableIdMap sync.Map
|
var tableIdMap sync.Map
|
||||||
|
|
||||||
func RefreshTableIdMap() {
|
func RefreshTableIdMap(t time.Duration) {
|
||||||
for {
|
for {
|
||||||
time.Sleep(time.Minute * 10)
|
time.Sleep(t)
|
||||||
tableIdMap.Range(func(key, value interface{}) bool {
|
tableIdMap.Range(func(key, value interface{}) bool {
|
||||||
tableIdMap.Delete(key)
|
tableIdMap.Delete(key)
|
||||||
return true
|
return true
|
||||||
@ -32,10 +32,6 @@ func RefreshTableIdMap() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewReportService() *ReportService {
|
|
||||||
return &ReportService{buff: bytes.Buffer{}}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ReportService) GetTableid(appid, appkey string) (table string, err error) {
|
func (this *ReportService) GetTableid(appid, appkey string) (table string, err error) {
|
||||||
|
|
||||||
this.buff.Reset()
|
this.buff.Reset()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user