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/dailyusage" "git.5iot.com/iotlcm-public/iotlcm-worker-svr/internal/producer/monthlyusagehistory" ) // Missing settings retain the serial path; explicit invalid values fail closed. // Enabling channel mode requires validating idx_card_chan_key on the target DB. func loadHistoryUsageScanSettings(ctx context.Context, section string) (string, int, error) { mode := g.Cfg().MustGet(ctx, section+".producer.scanMode", "serial").String() concurrency := g.Cfg().MustGet(ctx, section+".producer.scanConcurrency", 4).Int() var err error switch section { case "trafficUsageDailySync": err = dailyusage.ValidateScanSettings(mode, concurrency) case "trafficUsageMonthlyHistorySync": err = monthlyusagehistory.ValidateScanSettings(mode, concurrency) default: return "", 0, gerror.Newf("unknown history usage config section %q", section) } if err != nil { return "", 0, gerror.Wrap(err, "load history usage scan settings") } return mode, concurrency, nil }