nft质押任务逻辑
This commit is contained in:
@@ -6,10 +6,18 @@ import (
|
||||
"github.com/robfig/cron/v3"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"nova_task/internal/job/earn"
|
||||
"nova_task/internal/job/pledge"
|
||||
"nova_task/internal/job/holder"
|
||||
"nova_task/internal/job/stake_settle"
|
||||
"nova_task/internal/svc"
|
||||
)
|
||||
|
||||
// cronList 定时器Builder列表
|
||||
var cronList = []func(context.Context, *svc.ServiceContext) cron.Job{
|
||||
earn.NewCron,
|
||||
holder.NewCron,
|
||||
stake_settle.NewCron,
|
||||
}
|
||||
|
||||
type Job struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
@@ -21,15 +29,13 @@ type Spec interface {
|
||||
Spec() string
|
||||
}
|
||||
|
||||
// NewJob 创建定时器服务
|
||||
func NewJob(svcCtx *svc.ServiceContext) *Job {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
var cronList = []cron.Job{
|
||||
earn.NewEarn(ctx, svcCtx),
|
||||
pledge.NewPledge(ctx, svcCtx),
|
||||
}
|
||||
var err error
|
||||
c := cron.New()
|
||||
for _, cr := range cronList {
|
||||
c := cron.New(cron.WithSeconds())
|
||||
for _, cf := range cronList {
|
||||
cr := cf(ctx, svcCtx)
|
||||
if cs, ok := cr.(Spec); ok {
|
||||
spec := cs.Spec()
|
||||
if spec == "" {
|
||||
|
||||
Reference in New Issue
Block a user