123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package crontask
- import (
- "context"
- "wechat-api/internal/svc"
- "github.com/robfig/cron/v3"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type CronTask struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewCronTask(ctx context.Context, svcCtx *svc.ServiceContext) *CronTask {
- return &CronTask{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func ScheduleRun(c *cron.Cron, serverCtx *svc.ServiceContext) {
- //l := NewCronTask(context.Background(), serverCtx)
- //c.AddFunc("* * * * *", func() {
- // l.sendMsg()
- //})
- //
- //sendWx := NewCronTask(context.Background(), serverCtx)
- //c.AddFunc("* * * * *", func() {
- // sendWx.sendWx()
- //})
- //
- //sendWxOnTimeout := NewCronTask(context.Background(), serverCtx)
- //c.AddFunc("* * * * *", func() {
- // sendWxOnTimeout.sendWxOnTimeout()
- //})
- //
- //computeStatistic := NewCronTask(context.Background(), serverCtx)
- //c.AddFunc("0 * * * *", func() {
- // computeStatistic.computeStatistic()
- //})
- //syncWx := NewCronTask(context.Background(), serverCtx)
- //c.AddFunc("*/30 * * * *", func() {
- // syncWx.syncWx()
- //})
- contactForm := NewCronTask(context.Background(), serverCtx)
- c.AddFunc("@every 1m", func() {
- contactForm.analyze()
- })
- //l = NewCronTask(context.Background(), serverCtx)
- //c.AddFunc("* * * * *", func() {
- // MaxWorker := 10
- // MaxChannel := 3
- // l.compApiCallback(MaxWorker, MaxChannel)
- //})
- }
|