计划任务修改,act与kv使用协程方式执行,不影响其他任务

This commit is contained in:
ayflying
2025-09-01 18:12:58 +08:00
parent 95539038c0
commit 50cfc23ad2
6 changed files with 31 additions and 12 deletions

View File

@@ -5,6 +5,10 @@
package service
import (
"context"
)
type (
IGameKv interface {
// SavesV1 方法
@@ -12,7 +16,7 @@ type (
// @Description: 保存用户KV数据列表。
// @receiver s: sGameKv的实例。
// @return err: 错误信息如果操作成功则为nil。
SavesV1() (err error)
SavesV1(ctx context.Context) (err error)
}
)

View File

@@ -38,8 +38,8 @@ type (
// @receiver s: sSystemCron的实例代表一个调度系统。
// @param typ: 任务的类型,决定该任务将被添加到哪个列表中。对应不同的时间间隔。
// @param _func: 要添加的任务函数该函数执行时应该返回一个error。
// @param unique: 是否只在唯一服务器上执行
AddCronV2(typ v1.CronType, _func func(context.Context) error, unique ...bool)
// @param _onlyMain: 是否只在服务器上执行一次,true 唯一执行false 全局执行不判断唯一
AddCronV2(typ v1.CronType, _func func(context.Context) error, _onlyMain ...bool)
// StartCron 开始计划任务执行
//
// @Description: