chore: 并入 iotlcm-worker-svr 历史到 worker-svr/(原提交 96f0f4e)
This commit is contained in:
@@ -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/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
|
||||
}
|
||||
Reference in New Issue
Block a user