chore: 并入 iotlcm-admin-svr 历史到 admin-svr/(原提交 49818c6)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user