优化表结构,重构模型,重新实现基于白银网关的提取节点流程
This commit is contained in:
29
web/web.go
29
web/web.go
@@ -8,6 +8,7 @@ import (
|
||||
"platform/web/events"
|
||||
base "platform/web/globals"
|
||||
"platform/web/tasks"
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/hibiken/asynq"
|
||||
@@ -32,6 +33,10 @@ func RunApp(pCtx context.Context) error {
|
||||
return RunTask(ctx)
|
||||
})
|
||||
|
||||
g.Go(func() error {
|
||||
return RunSchedule(ctx)
|
||||
})
|
||||
|
||||
return g.Wait()
|
||||
}
|
||||
|
||||
@@ -65,13 +70,35 @@ func RunWeb(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func RunTask(ctx context.Context) error {
|
||||
func RunSchedule(ctx context.Context) error {
|
||||
var scheduler = asynq.NewSchedulerFromRedisClient(base.Redis, &asynq.SchedulerOpts{
|
||||
Location: time.Local,
|
||||
})
|
||||
|
||||
scheduler.Register("* * * * *", events.NewFlushGateway())
|
||||
|
||||
// 停止服务
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
scheduler.Shutdown()
|
||||
}()
|
||||
|
||||
// 启动服务
|
||||
err := scheduler.Run()
|
||||
if err != nil {
|
||||
return fmt.Errorf("调度服务运行失败: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func RunTask(ctx context.Context) error {
|
||||
var server = asynq.NewServerFromRedisClient(base.Redis, asynq.Config{})
|
||||
|
||||
var mux = asynq.NewServeMux()
|
||||
mux.HandleFunc(events.RemoveChannel, tasks.HandleRemoveChannel)
|
||||
mux.HandleFunc(events.CancelTrade, tasks.HandleCancelTrade)
|
||||
mux.HandleFunc(events.FlushGateway, tasks.HandleFlushGateway)
|
||||
|
||||
// 停止服务
|
||||
go func() {
|
||||
|
||||
Reference in New Issue
Block a user