Files
data-engine/service/sync/helpers.go
T
2026-07-16 14:34:06 +08:00

71 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
}
// GetSyncTimeout 获取单次同步超时时间(分钟,默认120),全量超大表可适当调大
func GetSyncTimeout(ctx context.Context) int {
t := g.Cfg().MustGet(ctx, "sync.sync_timeout_minutes", 120).Int()
if t < 1 {
return 120
}
return t
}
// GetFullSyncIntervalHours 获取全量同步间隔(小时;0=禁用自动全量,首次全量后只走增量)
func GetFullSyncIntervalHours(ctx context.Context) int {
h := g.Cfg().MustGet(ctx, "sync.full_sync_interval_hours", 0).Int()
if h < 0 {
return 0
}
return h
}
// GetDefaultLookbackDays 获取全量同步默认回溯天数(默认90)
func GetDefaultLookbackDays(ctx context.Context) int {
d := g.Cfg().MustGet(ctx, "sync.default_lookback_days", 90).Int()
if d < 1 {
return 90
}
return d
}