mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-11 22:00:27 +08:00
优化代码
This commit is contained in:
@@ -141,6 +141,10 @@ func (this *HTTPAccessLogDAO) CreateHTTPAccessLogs(tx *dbs.Tx, accessLogs []*pb.
|
|||||||
|
|
||||||
// DumpAccessLogsFromQueue 从队列导入访问日志
|
// DumpAccessLogsFromQueue 从队列导入访问日志
|
||||||
func (this *HTTPAccessLogDAO) DumpAccessLogsFromQueue(size int) (hasMore bool, err error) {
|
func (this *HTTPAccessLogDAO) DumpAccessLogsFromQueue(size int) (hasMore bool, err error) {
|
||||||
|
if size <= 0 {
|
||||||
|
size = 100
|
||||||
|
}
|
||||||
|
|
||||||
var dao = randomHTTPAccessLogDAO()
|
var dao = randomHTTPAccessLogDAO()
|
||||||
if dao == nil {
|
if dao == nil {
|
||||||
dao = &HTTPAccessLogDAOWrapper{
|
dao = &HTTPAccessLogDAOWrapper{
|
||||||
@@ -162,10 +166,6 @@ func (this *HTTPAccessLogDAO) DumpAccessLogsFromQueue(size int) (hasMore bool, e
|
|||||||
_ = tx.Commit()
|
_ = tx.Commit()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if size <= 0 {
|
|
||||||
size = 1_000_000
|
|
||||||
}
|
|
||||||
|
|
||||||
// 复制变量,防止中途改变
|
// 复制变量,防止中途改变
|
||||||
var oldQueue = oldAccessLogQueue
|
var oldQueue = oldAccessLogQueue
|
||||||
var newQueue = accessLogQueue
|
var newQueue = accessLogQueue
|
||||||
@@ -791,6 +791,9 @@ func (this *HTTPAccessLogDAO) SetupQueue() {
|
|||||||
|
|
||||||
accessLogQueuePercent = config.Percent
|
accessLogQueuePercent = config.Percent
|
||||||
accessLogCountPerSecond = config.CountPerSecond
|
accessLogCountPerSecond = config.CountPerSecond
|
||||||
|
if accessLogCountPerSecond <= 0 {
|
||||||
|
accessLogCountPerSecond = 10_000
|
||||||
|
}
|
||||||
if config.MaxLength <= 0 {
|
if config.MaxLength <= 0 {
|
||||||
config.MaxLength = 100_000
|
config.MaxLength = 100_000
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user