31 lines
983 B
Go
31 lines
983 B
Go
package tasks
|
|
|
|
import (
|
|
"context"
|
|
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/service"
|
|
"time"
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
)
|
|
|
|
func init() {
|
|
RegisterInnerTask("sync_traffic_usage_daily", "SyncTrafficUsageDaily")
|
|
}
|
|
|
|
// SyncTrafficUsageDaily publishes one command for Worker to execute the
|
|
// previous-day usage full sync. Admin no longer scans cards itself: Worker owns
|
|
// the scan, per-channel pacing, rounds, failure pool and replay.
|
|
func (t Task) SyncTrafficUsageDaily() {
|
|
t.runWithRedisJobLock(context.Background(), redisJobLockOptions{
|
|
InvokeTarget: "sync_traffic_usage_daily",
|
|
Period: -1,
|
|
TTL: 30 * time.Minute,
|
|
}, func(ctx context.Context) {
|
|
if err := service.TrafficUsageDailySync().StartDaily(ctx); err != nil {
|
|
// The timer must fail visibly when the start command cannot be
|
|
// published; Worker owns the actual full scan and overlap decision.
|
|
g.Log().Errorf(ctx, "start daily usage full sync failed: %+v", err)
|
|
}
|
|
})
|
|
}
|