重构数据引擎
This commit is contained in:
43
service/sync/helpers.go
Normal file
43
service/sync/helpers.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package sync
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// GetSyncPageSize 获取分页大小(默认100)
|
||||
func GetSyncPageSize(ctx context.Context) int {
|
||||
ps := g.Cfg().MustGet(ctx, "sync.page_size", 100).Int()
|
||||
if ps < 1 || ps > 100 {
|
||||
return 100
|
||||
}
|
||||
return ps
|
||||
}
|
||||
|
||||
// GetSyncConcurrency 获取并发数(默认5)
|
||||
func GetSyncConcurrency(ctx context.Context) int {
|
||||
c := g.Cfg().MustGet(ctx, "sync.concurrency", 5).Int()
|
||||
if c < 1 {
|
||||
return 1
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// GetSyncInterval 获取同步间隔(分钟,默认60)
|
||||
func GetSyncInterval(ctx context.Context) int {
|
||||
m := g.Cfg().MustGet(ctx, "sync.sync_interval_minutes", 60).Int()
|
||||
if m < 5 {
|
||||
return 60
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
// GetRetryCount 获取重试次数(默认3)
|
||||
func GetRetryCount(ctx context.Context) int {
|
||||
r := g.Cfg().MustGet(ctx, "sync.retry_count", 3).Int()
|
||||
if r < 0 {
|
||||
return 3
|
||||
}
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user