mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-08 03:00:26 +08:00
修复多个日志数据库节点写入NS日志时分布不平均的问题
This commit is contained in:
@@ -100,21 +100,33 @@ func randomHTTPAccessLogDAO() (dao *HTTPAccessLogDAOWrapper) {
|
||||
return daoList[0]
|
||||
}
|
||||
|
||||
return daoList[rands.Int(0, len(daoList)-1)]
|
||||
return daoList[rands.Int(0, l-1)]
|
||||
}
|
||||
|
||||
func randomNSAccessLogDAO() (dao *NSAccessLogDAOWrapper) {
|
||||
accessLogLocker.RLock()
|
||||
defer accessLogLocker.RUnlock()
|
||||
if len(nsAccessLogDAOMapping) == 0 {
|
||||
dao = nil
|
||||
} else {
|
||||
for _, d := range nsAccessLogDAOMapping {
|
||||
dao = d
|
||||
break
|
||||
}
|
||||
}
|
||||
accessLogLocker.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
var daoList = []*NSAccessLogDAOWrapper{}
|
||||
|
||||
for _, d := range nsAccessLogDAOMapping {
|
||||
daoList = append(daoList, d)
|
||||
}
|
||||
|
||||
var l = len(daoList)
|
||||
if l == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if l == 1 {
|
||||
return daoList[0]
|
||||
}
|
||||
|
||||
return daoList[rands.Int(0, l-1)]
|
||||
}
|
||||
|
||||
func findNSAccessLogTableName(db *dbs.DB, day string) (tableName string, ok bool, err error) {
|
||||
|
||||
Reference in New Issue
Block a user