chore: 并入 iotlcm-worker-svr 历史到 worker-svr/(原提交 96f0f4e)

This commit is contained in:
MiFaZhan
2026-11-02 13:28:03 +08:00
422 changed files with 80993 additions and 0 deletions
@@ -0,0 +1,31 @@
package worker
import (
"context"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"git.5iot.com/iotlcm-public/iotlcm-worker-svr/internal/producer/monthlyusage"
)
// Startup-only. Explicit zero/negative concurrency and invalid modes fail
// initialization; omitted concurrency defaults to four channel queries.
func loadMonthlyUsageProducerConfig(ctx context.Context) (monthlyusage.Config, error) {
config := monthlyusage.Config{
ScanConcurrency: g.Cfg().MustGet(ctx, "trafficUsageFullSync.producer.scanConcurrency", 4).Int(),
PageSize: g.Cfg().MustGet(ctx, "trafficUsageFullSync.producer.pageSize", 100).Int(),
GlobalHighWaterMark: g.Cfg().MustGet(ctx, "trafficUsageFullSync.producer.globalHighWaterMark", 0).Int64(),
ChannelHighWaterMark: g.Cfg().MustGet(ctx, "trafficUsageFullSync.producer.channelHighWaterMark", 0).Int64(),
PollInterval: g.Cfg().MustGet(ctx, "trafficUsageFullSync.producer.pollInterval", "2s").Duration(),
RunLockKey: g.Cfg().MustGet(ctx, "trafficUsageFullSync.producer.runLockKey", "flow:producer:active").String(),
RunLockTTL: g.Cfg().MustGet(ctx, "trafficUsageFullSync.producer.runLockTTL", "5m").Duration(),
RoundRetryEnabled: true,
MaxRounds: g.Cfg().MustGet(ctx, "trafficUsageFullSync.retry.maxRounds", 5).Int(),
FailureRetention: g.Cfg().MustGet(ctx, "trafficUsageFullSync.retry.failureRetention", "720h").Duration(),
}
if err := monthlyusage.ValidateScanSettings(config.ScanConcurrency); err != nil {
return monthlyusage.Config{}, gerror.Wrap(err, "load monthly usage producer config")
}
return config, nil
}