订单超时任务系统

This commit is contained in:
yml
2026-05-22 18:16:05 +08:00
parent 55477d0ac6
commit 6f915b37d3
9 changed files with 404 additions and 2 deletions
+7
View File
@@ -10,6 +10,7 @@ import (
"hfb_sys/backend/internal/config"
"hfb_sys/backend/internal/database"
"hfb_sys/backend/internal/jobs/ordertimeout"
"hfb_sys/backend/internal/router"
"go.uber.org/zap"
@@ -50,6 +51,11 @@ func main() {
}
engine := router.New(cfg, deps, logger)
jobCtx, stopJobs := context.WithCancel(context.Background())
defer stopJobs()
if deps.DB != nil {
ordertimeout.New(deps.DB, logger).Start(jobCtx)
}
server := &http.Server{
Addr: cfg.AppAddr,
Handler: engine,
@@ -66,6 +72,7 @@ func main() {
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
stopJobs()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()