Compare commits

...

42 Commits

Author SHA1 Message Date
李光春 9ffa6c2c05 - update
1 year ago
李光春 cd06d7d7e9 - update
1 year ago
李光春 7f12ec6a01 - add next_run_time
2 years ago
李光春 9469dcc3d6 - update config
2 years ago
李光春 78ed7bdfd8 - update time
2 years ago
李光春 3e404e4454 - update ip
2 years ago
李光春 bb6f68d444 - update system
2 years ago
李光春 60b50bf6f8 - update
2 years ago
李光春 11884afa4f - update
2 years ago
李光春 625deb44ca - update
2 years ago
李光春 d84a9656a7 - update ip
2 years ago
李光春 3d5d7c3a7d - update context
2 years ago
李光春 3a9b47cc7f - update db
2 years ago
李光春 5d910fb616 - update db
2 years ago
李光春 a2f2689d10 - update mongo
2 years ago
李光春 883fcec2cb - update mongo
2 years ago
李光春 2c6cf23f1b - update
2 years ago
李光春 e015e8f77d - update ip
2 years ago
李光春 d7a75aaac3 - update config
2 years ago
李光春 e4858bb504 - update lock
2 years ago
李光春 44fdf7efe0 - update lock
2 years ago
李光春 dcbcbbe079 - update fun
2 years ago
李光春 21c597f0f5 - update
2 years ago
李光春 19adea0395 - 移除mongo
2 years ago
李光春 882cb83ec8 - update mongo
2 years ago
李光春 1d5d63b0de - update mongo
2 years ago
李光春 4e1dc1e1b1 - update
2 years ago
李光春 b53a7490ce - update redis
2 years ago
李光春 917a716c90 - update
2 years ago
李光春 fbb4ccb197 - update
2 years ago
李光春 1bb38af4d7 - update gorm model
2 years ago
李光春 6b3b29d0c2 - update gorm model
2 years ago
李光春 1d1be8330b - update run_id
2 years ago
李光春 79b18ef741 - update error
2 years ago
李光春 049585a1fa - update lock
2 years ago
李光春 bab21c66bc - update lock
2 years ago
李光春 c66aa424b3 - update mongo model
2 years ago
李光春 649ace79cf - update mongo model
2 years ago
李光春 f7b6e6c8bc - update
2 years ago
李光春 d57ee8daaf - add vendor
2 years ago
李光春 7cf8704ec8 - update model
2 years ago
李光春 48494e8a9e - update model
2 years ago

@ -1,40 +0,0 @@
package gojobs
import (
"context"
"go.dtapp.net/gojobs/jobs_gorm_model"
"go.dtapp.net/gotime"
"gorm.io/gorm"
)
// CheckManyTask 多任务检查
func (c *Client) CheckManyTask(ctx context.Context, tx *gorm.DB, vs []jobs_gorm_model.Task) {
if len(vs) > 0 {
for _, v := range vs {
diffInSecondWithAbs := gotime.Current().DiffInSecondWithAbs(gotime.SetCurrent(v.UpdatedAt).Time)
if diffInSecondWithAbs >= v.Frequency*3 {
if c.config.debug == true {
c.zapLog.WithTraceId(ctx).Sugar().Infof("[jobs.CheckManyTask]每隔%v秒任务%v相差%v秒\n", v.Frequency, v.Id, diffInSecondWithAbs)
}
err := tx.Where("task_id = ?", v.Id).Where("run_id = ?", v.RunId).Delete(&jobs_gorm_model.TaskLogRun{}).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("删除失败:%s", err.Error())
}
}
}
}
}
// CheckSingleTask 单任务检查
func (c *Client) CheckSingleTask(ctx context.Context, tx *gorm.DB, v jobs_gorm_model.Task) {
diffInSecondWithAbs := gotime.Current().DiffInSecondWithAbs(gotime.SetCurrent(v.UpdatedAt).Time)
if diffInSecondWithAbs >= v.Frequency*3 {
if c.config.debug == true {
c.zapLog.WithTraceId(ctx).Sugar().Infof("[jobs.CheckManyTask]每隔%v秒任务%v相差%v秒\n", v.Frequency, v.Id, diffInSecondWithAbs)
}
err := tx.Where("task_id = ?", v.Id).Where("run_id = ?", v.RunId).Delete(&jobs_gorm_model.TaskLogRun{}).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("删除失败:%s", err.Error())
}
}
}

@ -3,19 +3,10 @@ package gojobs
import (
"context"
"go.dtapp.net/dorm"
"go.dtapp.net/goip"
"go.dtapp.net/golog"
)
// client *dorm.GormClient
type gormClientFun func() *dorm.GormClient
// client *dorm.MongoClient
// databaseName string
type mongoClientFun func() (*dorm.MongoClient, string)
// client *dorm.RedisClient
type redisClientFun func() *dorm.RedisClient
// 前缀
// lockKeyPrefix 锁Key前缀 xxx_lock
// lockKeySeparator 锁Key分隔符 :
@ -25,28 +16,38 @@ type redisPrefixFun func() (lockKeyPrefix, lockKeySeparator, cornKeyPrefix, corn
// ClientConfig 实例配置
type ClientConfig struct {
GormClientFun gormClientFun // 数据库驱动
MongoClientFun mongoClientFun // 数据库驱动
RedisClientFun redisClientFun // 数据库驱动
RedisPrefixFun redisPrefixFun // 前缀
Debug bool // 日志开关
ZapLog *golog.ZapLog // 日志服务
CurrentIp string // 当前ip
GormClientFun dorm.GormClientFun // 数据库驱动
MongoClientFun dorm.MongoClientFun // 数据库驱动
RedisClientFun dorm.RedisClientFun // 数据库驱动
RedisPrefixFun redisPrefixFun // 前缀
ZapLog *golog.ZapLog // 日志服务
CurrentIp string // 当前ip
}
// Client 实例
type Client struct {
zapLog *golog.ZapLog // 日志服务
config struct {
debug bool // 日志开关
runVersion string // 运行版本
os string // 系统类型
arch string // 系统架构
maxProCs int // CPU核数
version string // GO版本
macAddrS string // Mac地址
insideIp string // 内网ip
outsideIp string // 外网ip
gormClient *dorm.GormClient // 数据库
mongoClient *dorm.MongoClient // 数据库
zapLog *golog.ZapLog // 日志服务
config struct {
systemHostname string // 主机名
systemOs string // 系统类型
systemVersion string // 系统版本
systemKernel string // 系统内核
systemKernelVersion string // 系统内核版本
systemBootTime uint64 // 系统开机时间
cpuCores int // CPU核数
cpuModelName string // CPU型号名称
cpuMhz float64 // CPU兆赫
systemInsideIp string // 内网ip
systemOutsideIp string // 外网ip
goVersion string // go版本
sdkVersion string // sdk版本
mongoVersion string // mongo版本
mongoSdkVersion string // mongo sdk版本
redisVersion string // redis版本
redisSdkVersion string // redis sdk版本
logVersion string // log版本
}
cache struct {
redisClient *dorm.RedisClient // 数据库
@ -56,10 +57,9 @@ type Client struct {
cornKeyPrefix string // 任务Key前缀 xxx_cron
cornKeyCustom string // 任务Key自定义
}
db struct {
gormClient *dorm.GormClient // 数据库
mongoClient *dorm.MongoClient // 数据库
mongoDatabaseName string // 数据库名
mongoConfig struct {
stats bool // 状态
databaseName string // 库名
}
}
@ -72,21 +72,24 @@ func NewClient(config *ClientConfig) (*Client, error) {
c.zapLog = config.ZapLog
c.config.debug = config.Debug
if config.CurrentIp == "" {
if config.CurrentIp != "" && config.CurrentIp != "0.0.0.0" {
c.config.systemOutsideIp = config.CurrentIp
}
c.config.systemOutsideIp = goip.IsIp(c.config.systemOutsideIp)
if c.config.systemOutsideIp == "" {
return nil, currentIpNoConfig
}
c.config.outsideIp = config.CurrentIp
// 缓存
// 配置缓存
redisClient := config.RedisClientFun()
if redisClient != nil && redisClient.Db != nil {
if redisClient != nil && redisClient.GetDb() != nil {
c.cache.redisClient = redisClient
c.cache.redisLockClient = c.cache.redisClient.NewLock()
} else {
return nil, redisPrefixFunNoConfig
}
// 缓存前缀
// 配置缓存前缀
c.cache.lockKeyPrefix, c.cache.lockKeySeparator, c.cache.cornKeyPrefix, c.cache.cornKeyCustom = config.RedisPrefixFun()
if c.cache.lockKeyPrefix == "" || c.cache.lockKeySeparator == "" || c.cache.cornKeyPrefix == "" || c.cache.cornKeyCustom == "" {
return nil, redisPrefixFunNoConfig
@ -95,37 +98,32 @@ func NewClient(config *ClientConfig) (*Client, error) {
// 配置信息
c.setConfig(ctx)
// 数据库
// 配置关系数据库
gormClient := config.GormClientFun()
if gormClient != nil && gormClient.Db != nil {
c.db.gormClient = gormClient
if gormClient != nil && gormClient.GetDb() != nil {
c.gormClient = gormClient
c.autoMigrateTask()
c.autoMigrateTaskIp()
c.autoMigrateTaskLog()
c.autoMigrateTaskLogRun()
c.autoMigrateTask(ctx)
c.autoMigrateTaskLog(ctx)
} else {
return nil, gormClientFunNoConfig
}
// 数据库
// 配置非关系数据库
mongoClient, databaseName := config.MongoClientFun()
if mongoClient != nil && mongoClient.Db != nil {
c.db.mongoClient = mongoClient
if mongoClient != nil && mongoClient.GetDb() != nil {
c.mongoClient = mongoClient
if databaseName == "" {
return nil, mongoClientFunNoConfig
} else {
c.mongoConfig.databaseName = databaseName
}
c.db.mongoDatabaseName = databaseName
c.mongoCreateCollectionTask(ctx)
c.mongoCreateIndexesTask(ctx)
c.mongoCreateIndexesTaskIp(ctx)
c.mongoCreateCollectionTaskLog(ctx)
c.mongoCreateIndexesTaskLog(ctx)
c.mongoCreateCollectionTaskLogRun(ctx)
c.mongoCreateIndexesTaskLogRun(ctx)
c.mongoCreateCollectionTaskIssueRecord(ctx)
c.mongoCreateCollectionTaskReceiveRecord(ctx)
TaskLog{}.createCollection(ctx, c.zapLog, c.mongoClient, c.mongoConfig.databaseName)
TaskLog{}.createIndexes(ctx, c.zapLog, c.mongoClient, c.mongoConfig.databaseName)
c.mongoConfig.stats = true
}
return c, nil

@ -2,17 +2,87 @@ package gojobs
import (
"context"
"go.dtapp.net/goarray"
"github.com/go-redis/redis/v9"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/host"
"go.dtapp.net/goip"
"go.dtapp.net/golog"
"go.mongodb.org/mongo-driver/version"
"log"
"runtime"
)
type systemResult struct {
SystemHostname string // 主机名
SystemOs string // 系统类型
SystemVersion string // 系统版本
SystemKernel string // 系统内核
SystemKernelVersion string // 系统内核版本
SystemUpTime uint64 // 系统运行时间
SystemBootTime uint64 // 系统开机时间
CpuCores int // CPU核数
CpuModelName string // CPU型号名称
CpuMhz float64 // CPU兆赫
}
func getSystem() (result systemResult) {
hInfo, err := host.Info()
if err != nil {
log.Printf("getSystem.host.Info%s\n", err)
}
result.SystemHostname = hInfo.Hostname
result.SystemOs = hInfo.OS
result.SystemVersion = hInfo.PlatformVersion
result.SystemKernel = hInfo.KernelArch
result.SystemKernelVersion = hInfo.KernelVersion
result.SystemUpTime = hInfo.Uptime
if hInfo.BootTime != 0 {
result.SystemBootTime = hInfo.BootTime
}
hCpu, err := cpu.Times(true)
if err != nil {
log.Printf("getSystem.cpu.Times%s\n", err)
}
result.CpuCores = len(hCpu)
cInfo, err := cpu.Info()
if err != nil {
log.Printf("getSystem.cpu.Info%s\n", err)
}
if len(cInfo) > 0 {
result.CpuModelName = cInfo[0].ModelName
result.CpuMhz = cInfo[0].Mhz
}
return result
}
func (c *Client) setConfig(ctx context.Context) {
c.config.runVersion = Version
c.config.os = runtime.GOOS
c.config.arch = runtime.GOARCH
c.config.maxProCs = runtime.GOMAXPROCS(0)
c.config.version = runtime.Version()
c.config.macAddrS = goarray.TurnString(goip.GetMacAddr(ctx))
c.config.insideIp = goip.GetInsideIp(ctx)
info := getSystem()
c.config.systemHostname = info.SystemHostname
c.config.systemOs = info.SystemOs
c.config.systemVersion = info.SystemVersion
c.config.systemKernel = info.SystemKernel
c.config.systemKernelVersion = info.SystemKernelVersion
c.config.systemBootTime = info.SystemBootTime
c.config.cpuCores = info.CpuCores
c.config.cpuModelName = info.CpuModelName
c.config.cpuMhz = info.CpuMhz
c.config.systemInsideIp = goip.GetInsideIp(ctx)
c.config.sdkVersion = Version
c.config.goVersion = runtime.Version()
c.config.mongoSdkVersion = version.Driver
c.config.redisSdkVersion = redis.Version()
c.config.logVersion = golog.Version
}

@ -1,6 +1,6 @@
package gojobs
const (
Version = "1.0.77"
Version = "1.0.113"
SpecifyIpNull = "0.0.0.0"
)

@ -1,10 +1,12 @@
package gojobs
import (
"context"
"errors"
"fmt"
"go.dtapp.net/gojobs/jobs_gorm_model"
"go.dtapp.net/gostring"
"go.dtapp.net/gotime"
"gorm.io/gorm"
)
@ -18,13 +20,13 @@ type ConfigCreateInCustomId struct {
Type string // 类型
TypeName string // 类型名称
SpecifyIp string // 指定外网IP
CurrentIp string // 当前ip
CurrentIp string // 当前外网IP
}
// CreateInCustomId 创建正在运行任务
func (c *Client) CreateInCustomId(config *ConfigCreateInCustomId) error {
func (c *Client) CreateInCustomId(ctx context.Context, config *ConfigCreateInCustomId) error {
if config.CurrentIp == "" {
config.CurrentIp = c.config.outsideIp
config.CurrentIp = c.config.systemOutsideIp
}
err := config.Tx.Create(&jobs_gorm_model.Task{
Status: TASK_IN,
@ -39,6 +41,7 @@ func (c *Client) CreateInCustomId(config *ConfigCreateInCustomId) error {
CreatedIp: config.CurrentIp,
SpecifyIp: config.SpecifyIp,
UpdatedIp: config.CurrentIp,
NextRunTime: gotime.Current().AfterSeconds(config.Frequency).Time,
}).Error
if err != nil {
return errors.New(fmt.Sprintf("创建[%s@%s]任务失败:%s", config.CustomId, config.Type, err.Error()))
@ -56,17 +59,17 @@ type ConfigCreateInCustomIdOnly struct {
Type string // 类型
TypeName string // 类型名称
SpecifyIp string // 指定外网IP
CurrentIp string // 当前ip
CurrentIp string // 当前外网IP
}
// CreateInCustomIdOnly 创建正在运行唯一任务
func (c *Client) CreateInCustomIdOnly(config *ConfigCreateInCustomIdOnly) error {
query := c.TaskTypeTakeIn(config.Tx, config.CustomId, config.Type)
func (c *Client) CreateInCustomIdOnly(ctx context.Context, config *ConfigCreateInCustomIdOnly) error {
query := c.TaskTypeTakeIn(ctx, config.Tx, config.CustomId, config.Type)
if query.Id != 0 {
return errors.New(fmt.Sprintf("%d:[%s@%s]任务已存在", query.Id, config.CustomId, config.Type))
return TaskIsExist
}
if config.CurrentIp == "" {
config.CurrentIp = c.config.outsideIp
config.CurrentIp = c.config.systemOutsideIp
}
err := config.Tx.Create(&jobs_gorm_model.Task{
Status: TASK_IN,
@ -81,6 +84,7 @@ func (c *Client) CreateInCustomIdOnly(config *ConfigCreateInCustomIdOnly) error
CreatedIp: config.CurrentIp,
SpecifyIp: config.SpecifyIp,
UpdatedIp: config.CurrentIp,
NextRunTime: gotime.Current().AfterSeconds(config.Frequency).Time,
}).Error
if err != nil {
return errors.New(fmt.Sprintf("创建[%s@%s]任务失败:%s", config.CustomId, config.Type, err.Error()))
@ -99,13 +103,13 @@ type ConfigCreateInCustomIdMaxNumber struct {
Type string // 类型
TypeName string // 类型名称
SpecifyIp string // 指定外网IP
CurrentIp string // 当前ip
CurrentIp string // 当前外网IP
}
// CreateInCustomIdMaxNumber 创建正在运行任务并限制数量
func (c *Client) CreateInCustomIdMaxNumber(config *ConfigCreateInCustomIdMaxNumber) error {
func (c *Client) CreateInCustomIdMaxNumber(ctx context.Context, config *ConfigCreateInCustomIdMaxNumber) error {
if config.CurrentIp == "" {
config.CurrentIp = c.config.outsideIp
config.CurrentIp = c.config.systemOutsideIp
}
err := config.Tx.Create(&jobs_gorm_model.Task{
Status: TASK_IN,
@ -121,6 +125,7 @@ func (c *Client) CreateInCustomIdMaxNumber(config *ConfigCreateInCustomIdMaxNumb
CreatedIp: config.CurrentIp,
SpecifyIp: config.SpecifyIp,
UpdatedIp: config.CurrentIp,
NextRunTime: gotime.Current().AfterSeconds(config.Frequency).Time,
}).Error
if err != nil {
return errors.New(fmt.Sprintf("创建[%s@%s]任务失败:%s", config.CustomId, config.Type, err.Error()))
@ -139,17 +144,17 @@ type ConfigCreateInCustomIdMaxNumberOnly struct {
Type string // 类型
TypeName string // 类型名称
SpecifyIp string // 指定外网IP
CurrentIp string // 当前ip
CurrentIp string // 当前外网IP
}
// CreateInCustomIdMaxNumberOnly 创建正在运行唯一任务并限制数量
func (c *Client) CreateInCustomIdMaxNumberOnly(config *ConfigCreateInCustomIdMaxNumberOnly) error {
query := c.TaskTypeTakeIn(config.Tx, config.CustomId, config.Type)
func (c *Client) CreateInCustomIdMaxNumberOnly(ctx context.Context, config *ConfigCreateInCustomIdMaxNumberOnly) error {
query := c.TaskTypeTakeIn(ctx, config.Tx, config.CustomId, config.Type)
if query.Id != 0 {
return errors.New(fmt.Sprintf("%d:[%s@%s]任务已存在", query.Id, config.CustomId, config.Type))
return TaskIsExist
}
if config.CurrentIp == "" {
config.CurrentIp = c.config.outsideIp
config.CurrentIp = c.config.systemOutsideIp
}
err := config.Tx.Create(&jobs_gorm_model.Task{
Status: TASK_IN,
@ -165,6 +170,7 @@ func (c *Client) CreateInCustomIdMaxNumberOnly(config *ConfigCreateInCustomIdMax
CreatedIp: config.CurrentIp,
SpecifyIp: config.SpecifyIp,
UpdatedIp: config.CurrentIp,
NextRunTime: gotime.Current().AfterSeconds(config.Frequency).Time,
}).Error
if err != nil {
return errors.New(fmt.Sprintf("创建[%s@%s]任务失败:%s", config.CustomId, config.Type, err.Error()))

@ -1,10 +1,12 @@
package gojobs
import (
"context"
"errors"
"fmt"
"go.dtapp.net/gojobs/jobs_gorm_model"
"go.dtapp.net/gostring"
"go.dtapp.net/gotime"
"gorm.io/gorm"
)
@ -18,18 +20,18 @@ type ConfigCreateWaitCustomId struct {
Type string // 类型
TypeName string // 类型名称
SpecifyIp string // 指定外网IP
CurrentIp string // 当前ip
CurrentIp string // 当前外网IP
}
// CreateWaitCustomId 创建正在运行任务
func (c *Client) CreateWaitCustomId(config *ConfigCreateWaitCustomId) error {
func (c *Client) CreateWaitCustomId(ctx context.Context, config *ConfigCreateWaitCustomId) error {
if config.CurrentIp == "" {
config.CurrentIp = c.config.outsideIp
config.CurrentIp = c.config.systemOutsideIp
}
err := config.Tx.Create(&jobs_gorm_model.Task{
Status: TASK_WAIT,
Params: config.Params,
StatusDesc: "首次添加任务",
StatusDesc: "首次添加等待任务",
Frequency: config.Frequency,
RunId: gostring.GetUuId(),
CustomId: config.CustomId,
@ -39,6 +41,7 @@ func (c *Client) CreateWaitCustomId(config *ConfigCreateWaitCustomId) error {
CreatedIp: config.CurrentIp,
SpecifyIp: config.SpecifyIp,
UpdatedIp: config.CurrentIp,
NextRunTime: gotime.Current().AfterSeconds(config.Frequency).Time,
}).Error
if err != nil {
return errors.New(fmt.Sprintf("创建[%s@%s]任务失败:%s", config.CustomId, config.Type, err.Error()))

@ -4,7 +4,8 @@ import "errors"
var (
currentIpNoConfig = errors.New("请配置 CurrentIp")
mongoClientFunNoConfig = errors.New("请配置 MongoClientFun")
redisPrefixFunNoConfig = errors.New("请配置 RedisPrefixFun")
gormClientFunNoConfig = errors.New("请配置 GormClientFun")
mongoClientFunNoConfig = errors.New("请配置 MongoClientFun")
TaskIsExist = errors.New("任务已存在")
)

@ -8,22 +8,22 @@ import (
// GetDb 获取数据库驱动
func (c *Client) GetDb() *gorm.DB {
return c.db.gormClient.Db
return c.gormClient.GetDb()
}
// GetMongoDb 获取数据库驱动
func (c *Client) GetMongoDb() *mongo.Client {
return c.db.mongoClient.Db
return c.mongoClient.GetDb()
}
// GetRedis 获取缓存数据库驱动
func (c *Client) GetRedis() *redis.Client {
return c.cache.redisClient.Db
return c.cache.redisClient.GetDb()
}
// GetCurrentIp 获取当前ip
func (c *Client) GetCurrentIp() string {
return c.config.outsideIp
return c.config.systemOutsideIp
}
// GetSubscribeAddress 获取订阅地址

@ -3,35 +3,34 @@ module go.dtapp.net/gojobs
go 1.19
require (
github.com/go-redis/redis/v9 v9.0.0-beta.2
github.com/go-redis/redis/v9 v9.0.0-rc.2
github.com/jasonlvhit/gocron v0.0.1
github.com/robfig/cron/v3 v3.0.1
go.dtapp.net/dorm v1.0.32
go.dtapp.net/goarray v1.0.1
go.dtapp.net/goip v1.0.28
go.dtapp.net/golog v1.0.67
github.com/shirou/gopsutil v3.21.11+incompatible
go.dtapp.net/dorm v1.0.54
go.dtapp.net/goip v1.0.39
go.dtapp.net/golog v1.0.102
go.dtapp.net/gostring v1.0.10
go.dtapp.net/gotime v1.0.5
go.dtapp.net/gotrace_id v1.0.6
go.mongodb.org/mongo-driver v1.10.1
gorm.io/gorm v1.23.8
go.mongodb.org/mongo-driver v1.11.0
gorm.io/gorm v1.24.2
)
require (
github.com/basgys/goxml2json v1.1.0 // indirect
github.com/beego/beego/v2 v2.0.5 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.8.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.0 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.13.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
@ -43,52 +42,56 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.6.6 // indirect
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/oschwald/geoip2-golang v1.8.0 // indirect
github.com/oschwald/maxminddb-golang v1.10.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/saracen/go7z v0.0.0-20191010121135-9c09b6bd7fda // indirect
github.com/saracen/solidblock v0.0.0-20190426153529-45df20abab6f // indirect
github.com/segmentio/fasthash v1.0.3 // indirect
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/syndtr/goleveldb v1.0.0 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/upper/db/v4 v4.6.0 // indirect
github.com/uptrace/bun v1.1.8 // indirect
github.com/uptrace/bun/dialect/mysqldialect v1.1.8 // indirect
github.com/uptrace/bun/dialect/pgdialect v1.1.8 // indirect
github.com/uptrace/bun/driver/pgdriver v1.1.8 // indirect
github.com/uptrace/bun v1.1.9 // indirect
github.com/uptrace/bun/dialect/mysqldialect v1.1.9 // indirect
github.com/uptrace/bun/dialect/pgdialect v1.1.9 // indirect
github.com/uptrace/bun/driver/pgdriver v1.1.9 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.dtapp.net/gorandom v1.0.1 // indirect
go.dtapp.net/gorequest v1.0.28 // indirect
go.dtapp.net/gorequest v1.0.36 // indirect
go.dtapp.net/gourl v1.0.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b // indirect
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/crypto v0.3.0 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/driver/mysql v1.3.6 // indirect
gorm.io/driver/postgres v1.3.9 // indirect
gorm.io/driver/mysql v1.4.4 // indirect
gorm.io/driver/postgres v1.4.5 // indirect
mellium.im/sasl v0.3.0 // indirect
modernc.org/ccgo/v3 v3.16.8 // indirect
xorm.io/builder v0.3.12 // indirect

130
go.sum

@ -27,8 +27,6 @@ github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/basgys/goxml2json v1.1.0 h1:4ln5i4rseYfXNd86lGEB+Vi652IsIXIvggKM/BhUKVw=
github.com/basgys/goxml2json v1.1.0/go.mod h1:wH7a5Np/Q4QoECFIU8zTQlZwZkrilY0itPfecMw41Dw=
github.com/beego/beego/v2 v2.0.5 h1:fa2TBWfKGDs35Ck9an9SVnpS0zM8sRTXlW8rFjpeYlE=
github.com/beego/beego/v2 v2.0.5/go.mod h1:CH2/JIaB4ceGYVQlYqTAFft4pVk/ol1ZkakUrUvAyns=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
@ -90,17 +88,19 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.11.0 h1:0W+xRM511GY47Yy3bZUbJVitCNg2BOGlCyvTqsp/xIw=
github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ=
github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-redis/redis/v9 v9.0.0-beta.2 h1:ZSr84TsnQyKMAg8gnV+oawuQezeJR11/09THcWCQzr4=
github.com/go-redis/redis/v9 v9.0.0-beta.2/go.mod h1:Bldcd/M/bm9HbnNPi/LUtYBSD8ttcZYBMupwMXhdU0o=
github.com/go-redis/redis/v9 v9.0.0-rc.2 h1:IN1eI8AvJJeWHjMW/hlFAv2sAfvTun2DVksDDJ3a6a0=
github.com/go-redis/redis/v9 v9.0.0-rc.2/go.mod h1:cgBknjwcBJa2prbnuHH/4k/Mlj4r0pWNV2HBanHujfY=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
@ -137,7 +137,7 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
@ -168,8 +168,6 @@ github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
@ -195,7 +193,6 @@ github.com/jackc/pgconn v1.8.1/go.mod h1:JV6m6b6jhjdmzchES0drzCcYcAHS1OPD5xu3OZ/
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
github.com/jackc/pgconn v1.11.0/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
github.com/jackc/pgconn v1.12.1/go.mod h1:ZkhRC59Llhrq3oSfrikvwQ5NaxYExr6twkdkMLaKono=
github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys=
github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI=
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
@ -215,7 +212,6 @@ github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwX
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.3.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y=
github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
@ -231,7 +227,6 @@ github.com/jackc/pgtype v1.7.0/go.mod h1:ZnHF+rMePVqDKaOfJVI4Q8IVvAQMryDlDkZnKOI
github.com/jackc/pgtype v1.8.0/go.mod h1:PqDKcEBtllAtk/2p6z6SHdXW5UB+MhE75tUol2OKexE=
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
github.com/jackc/pgtype v1.10.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgtype v1.11.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgtype v1.12.0 h1:Dlq8Qvcch7kiehm8wPGIW0W3KsCCHJnRacKW0UM8n5w=
github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
@ -244,7 +239,6 @@ github.com/jackc/pgx/v4 v4.11.0/go.mod h1:i62xJgdrtVDsnL3U8ekyrQXEwGNTRoG7/8r+CI
github.com/jackc/pgx/v4 v4.12.0/go.mod h1:fE547h6VulLPA3kySjfnSG/e2D861g/50JlVUa/ub60=
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
github.com/jackc/pgx/v4 v4.15.0/go.mod h1:D/zyOyXiaM1TmVWnOM18p0xdDtdakRBa0RsVGI3U3bw=
github.com/jackc/pgx/v4 v4.16.1/go.mod h1:SIhx0D5hoADaiXZVyv+3gSm3LCIIINTVO0PficsvWGQ=
github.com/jackc/pgx/v4 v4.17.2 h1:0Ut0rpeKwvIVbMQ1KbMBU4h6wxehBI535LK6Flheh8E=
github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw=
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
@ -275,8 +269,8 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:C
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM=
github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
@ -297,8 +291,8 @@ github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs=
github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
@ -358,7 +352,7 @@ github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q=
github.com/onsi/gomega v1.24.1 h1:KORJXNNTzJXzu4ScJWssJfJMnJ+2QJqhoQSRwNlze9E=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
@ -368,11 +362,15 @@ github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxS
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/oschwald/geoip2-golang v1.8.0 h1:KfjYB8ojCEn/QLqsDU0AzrJ3R5Qa9vFlx3z6SLNcKTs=
github.com/oschwald/geoip2-golang v1.8.0/go.mod h1:R7bRvYjOeaoenAp9sKRS8GX5bJWcZ0laWO5+DauEktw=
github.com/oschwald/maxminddb-golang v1.10.0 h1:Xp1u0ZhqkSuopaKmk1WwHtjF0H9Hd9181uj2MQ5Vndg=
github.com/oschwald/maxminddb-golang v1.10.0/go.mod h1:Y2ELenReaLAZ0b400URyGwvYxHV1dLIxBuyOsyYjHK0=
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg=
github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas=
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
@ -427,8 +425,8 @@ github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdh
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtrmhM=
github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY=
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 h1:DAYUYH5869yV94zvCES9F51oYtN5oGlwjxJJz7ZCnik=
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
@ -453,6 +451,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
@ -460,12 +459,17 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM=
github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI=
github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms=
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo=
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs=
@ -476,14 +480,14 @@ github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8=
github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/upper/db/v4 v4.6.0 h1:0VmASnqrl/XN8Ehoq++HBgZ4zRD5j3GXygW8FhP0C5I=
github.com/upper/db/v4 v4.6.0/go.mod h1:2mnRcPf+RcCXmVcD+o04LYlyu3UuF7ubamJia7CkN6s=
github.com/uptrace/bun v1.1.8 h1:slxuaP4LYWFbPRUmTtQhfJN+6eX/6ar2HDKYTcI50SA=
github.com/uptrace/bun v1.1.8/go.mod h1:iT89ESdV3uMupD9ixt6Khidht+BK0STabK/LeZE+B84=
github.com/uptrace/bun/dialect/mysqldialect v1.1.8 h1:gcL5iy0yUbuJJLkE+0G3vAUS/6GjPLkqFTtN2+tx7XU=
github.com/uptrace/bun/dialect/mysqldialect v1.1.8/go.mod h1:GQdbU4Yk/1qKVxfOieCAOC62ZM1c6qXUpgA1vxckEow=
github.com/uptrace/bun/dialect/pgdialect v1.1.8 h1:wayJhjYDPGv8tgOBLolbBtSFQ0TihFoo8E1T129UdA8=
github.com/uptrace/bun/dialect/pgdialect v1.1.8/go.mod h1:nNbU8PHTjTUM+CRtGmqyBb9zcuRAB8I680/qoFSmBUk=
github.com/uptrace/bun/driver/pgdriver v1.1.8 h1:gyL22axRQfjJS2Umq0erzJnp0bLOdUE8/USKZHPQB8o=
github.com/uptrace/bun/driver/pgdriver v1.1.8/go.mod h1:4tHK0h7a/UoldBoe9J3GU4tEYjr3mkd62U3Kq3PVk3E=
github.com/uptrace/bun v1.1.9 h1:6zs+YJcgw8oj67c+YmI8edQokDFeyR4BE/ykNWjGYYs=
github.com/uptrace/bun v1.1.9/go.mod h1:fpYRCGyruLCyP7dNjMfqulYn4VBP/fH0enc0j0yW/Cs=
github.com/uptrace/bun/dialect/mysqldialect v1.1.9 h1:TPK14lATldiJiIpwAVl4RzgoNkY+wo+7RVbNmGdYVsc=
github.com/uptrace/bun/dialect/mysqldialect v1.1.9/go.mod h1:C7tZ3CSfWNsjr9ujTedyeI8Zy5iCcaqnCGYObY9MFz0=
github.com/uptrace/bun/dialect/pgdialect v1.1.9 h1:V23SU89WfjqtePLFPRXVXCwmSyYb0XKeg8Z6BMXgyHg=
github.com/uptrace/bun/dialect/pgdialect v1.1.9/go.mod h1:+ux7PjC4NYsNMdGE9b2ERxCi2jJai8Z8zniXFExq0Ns=
github.com/uptrace/bun/driver/pgdriver v1.1.9 h1:Dy9g/EpgOG15RP3mDAuJd/hnfXAUdBsfxpg9On27M+Y=
github.com/uptrace/bun/driver/pgdriver v1.1.9/go.mod h1:YnPHzR4fT24PXrBTcadclXfdtkR9dYouqk2HwOiKf2g=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
@ -501,20 +505,20 @@ github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7Jul
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
go.dtapp.net/dorm v1.0.32 h1:kMU2on0t8e87qDvXEt8DlaM1DJjLBvUOaIGc5fNsgzY=
go.dtapp.net/dorm v1.0.32/go.mod h1:ocdIcMoJCLGngRNPSAa/1Hq+Mu1JDTxT0hH2QBlL2ik=
go.dtapp.net/goarray v1.0.1 h1:cHNHaJ2MFcuJPA1WKU2PM1EUZShS1vQqEH7n6YXsQVU=
go.dtapp.net/goarray v1.0.1/go.mod h1:/MPhlFCAhQyeNV1M0v1PAOOX33Sg705fVjUgMO12IBQ=
go.dtapp.net/goip v1.0.28 h1:wZt+wbzNhOLRUJnepG4c8HhUr4V9jNXOF6wJ1h7jUvU=
go.dtapp.net/goip v1.0.28/go.mod h1:ZqPPUvpOSzdtB/dEZFiaD0CBRZmvIzjDmm3XkpMC9Bo=
go.dtapp.net/golog v1.0.67 h1:HGNrc9zq1S0yXxPazG+Odpsgtv/g5qSw7p8XbKAU+RQ=
go.dtapp.net/golog v1.0.67/go.mod h1:KIUJMiZqj8BgPwvE/CqAuiKhysreEh2cz3Tf+sdYTM4=
go.dtapp.net/dorm v1.0.54 h1:yY3NqVSPKDsoLUrEkVzyM9hiZO95jLT1BALXErt+DAw=
go.dtapp.net/dorm v1.0.54/go.mod h1:9QRNnXLkHev7MllwpPq6OYusP8khujurXfMZv6p7CYo=
go.dtapp.net/goip v1.0.39 h1:6fEV0yrY3PNUK3lhEuMqxZJYEXzhbHannvsgZA7s7hE=
go.dtapp.net/goip v1.0.39/go.mod h1:9o6uaw0JCPvTwGFWRkznI8EidQ9bwWJ5dx02/7ZUnEM=
go.dtapp.net/golog v1.0.102 h1:WVfx+vxWODqPkYJNeLfxIENyQO3RCCWr5xLhhPauOpM=
go.dtapp.net/golog v1.0.102/go.mod h1:doXs2CQmQOMGhrZD7bRRzdUh+cYWfiugJEmpJWBeXDw=
go.dtapp.net/gorandom v1.0.1 h1:IWfMClh1ECPvyUjlqD7MwLq4mZdUusD1qAwAdsvEJBs=
go.dtapp.net/gorandom v1.0.1/go.mod h1:ZPdgalKpvFV/ATQqR0k4ns/F/IpITAZpx6WkWirr5Y8=
go.dtapp.net/gorequest v1.0.28 h1:EehFtF5WcvyZ9rB6MAQoI2kJkhR8Wv8tVgpoxXcb3sI=
go.dtapp.net/gorequest v1.0.28/go.mod h1:Nr0BIOXhapY3Es86hL7pN2c2PgjZwImcrWdMpLzHlJE=
go.dtapp.net/gorequest v1.0.36 h1:c3DqlQ1bvTwCOJ3gRnDE5nsg8iqnjEYmVAFHn3d8rpY=
go.dtapp.net/gorequest v1.0.36/go.mod h1:IbhBN1ID6CqMitHjAYdEBmhK1P5FVDLUeMl1JqxE3qY=
go.dtapp.net/gostring v1.0.10 h1:eG+1kQehdJUitj9Hfwy79SndMHYOB7ABpWkTs7mDGeQ=
go.dtapp.net/gostring v1.0.10/go.mod h1:L4kREy89a9AraMHB5tUjjl+5rxP1gpXkDouRKKuzT50=
go.dtapp.net/gotime v1.0.5 h1:12aNgB2ULpP6QgQHEUkLilZ4ASvhpFxMFQkBwn0par8=
@ -525,8 +529,8 @@ go.dtapp.net/gourl v1.0.0 h1:Zbe0GiMFyyRy2+bjbVsYulakH5d58w3CDZkUPonlMoQ=
go.dtapp.net/gourl v1.0.0/go.mod h1:x9A/pJ3iKDTb6Gu2RtJy2iHg56IowXIcIGQdogqpGjs=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
go.mongodb.org/mongo-driver v1.10.1 h1:NujsPveKwHaWuKUer/ceo9DzEe7HIj1SlJ6uvXZG0S4=
go.mongodb.org/mongo-driver v1.10.1/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
go.mongodb.org/mongo-driver v1.11.0 h1:FZKhBSTydeuffHj9CBjXlR8vQLee1cQyTWYPA6/tqiE=
go.mongodb.org/mongo-driver v1.11.0/go.mod h1:s7p5vEtfbeR1gYi6pnj3c3/urpbLv2T5Sfd6Rp2HBB8=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
@ -566,13 +570,12 @@ golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWP
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A=
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/exp v0.0.0-20181106170214-d68db9428509/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@ -583,8 +586,8 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -605,8 +608,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY=
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -617,8 +620,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc=
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@ -636,6 +639,7 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -653,8 +657,8 @@ golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY=
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -662,8 +666,9 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@ -683,7 +688,7 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.11 h1:loJ25fNOEhSXfHrpoGj91eCUThwdNX6u24rO1xnNteY=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@ -737,13 +742,14 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/mysql v1.3.6 h1:BhX1Y/RyALb+T9bZ3t07wLnPZBukt+IRkMn8UZSNbGM=
gorm.io/driver/mysql v1.3.6/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10c=
gorm.io/driver/postgres v1.3.9 h1:lWGiVt5CijhQAg0PWB7Od1RNcBw/jS4d2cAScBcSDXg=
gorm.io/driver/postgres v1.3.9/go.mod h1:qw/FeqjxmYqW5dBcYNBsnhQULIApQdk7YuuDPktVi1U=
gorm.io/gorm v1.23.7/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE=
gorm.io/driver/mysql v1.4.4 h1:MX0K9Qvy0Na4o7qSC/YI7XxqUw5KDw01umqgID+svdQ=
gorm.io/driver/mysql v1.4.4/go.mod h1:BCg8cKI+R0j/rZRQxeKis/forqRwRSYOR8OM3Wo6hOM=
gorm.io/driver/postgres v1.4.5 h1:mTeXTTtHAgnS9PgmhN2YeUbazYpLhUI1doLnw42XUZc=
gorm.io/driver/postgres v1.4.5/go.mod h1:GKNQYSJ14qvWkvPwXljMGehpKrhlDNsqYRr5HnYGncg=
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.24.1-0.20221019064659-5dd2bb482755/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
gorm.io/gorm v1.24.2 h1:9wR6CFD+G8nOusLdvkZelOEhpJVwwHzpQOUM+REd6U0=
gorm.io/gorm v1.24.2/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

@ -1,142 +1,167 @@
package gojobs
import (
"context"
"go.dtapp.net/gojobs/jobs_gorm_model"
"go.dtapp.net/gotime"
"gorm.io/gorm"
"log"
"strings"
)
// TaskTakeId 查询单任务
func (c *Client) TaskTakeId(tx *gorm.DB, id uint) (result jobs_gorm_model.Task) {
tx.Where("id = ?", id).Take(&result)
// TaskTakeId 编号查询任务
func (c *Client) TaskTakeId(ctx context.Context, tx *gorm.DB, id uint) (result jobs_gorm_model.Task) {
err := tx.Where("id = ?", id).Take(&result).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("编号查询任务:%v", err)
}
return result
}
// TaskTake 查询单任务
func (c *Client) TaskTake(tx *gorm.DB, customId string) (result jobs_gorm_model.Task) {
tx.Where("custom_id = ?", customId).Take(&result)
// TaskTake 自定义编号查询任务
func (c *Client) TaskTake(ctx context.Context, tx *gorm.DB, customId string) (result jobs_gorm_model.Task) {
err := tx.Where("custom_id = ?", customId).Take(&result).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("自定义编号查询任务:%v", err)
}
return result
}
// 查询单任务
func (c *Client) taskTake(tx *gorm.DB, customId, status string) (result jobs_gorm_model.Task) {
tx.Where("custom_id = ?", customId).Where("status = ?", status).Take(&result)
// 自定义编号加状态查询任务
func (c *Client) taskTake(ctx context.Context, tx *gorm.DB, customId, status string) (result jobs_gorm_model.Task) {
err := tx.Where("custom_id = ?", customId).Where("status = ?", status).Take(&result).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("自定义编号加状态查询任务:%v", err)
}
return result
}
// TaskTakeIn 查询单任务 - 任务运行
func (c *Client) TaskTakeIn(tx *gorm.DB, customId string) jobs_gorm_model.Task {
return c.taskTake(tx, customId, TASK_IN)
func (c *Client) TaskTakeIn(ctx context.Context, tx *gorm.DB, customId string) jobs_gorm_model.Task {
return c.taskTake(ctx, tx, customId, TASK_IN)
}
// TaskTakeSuccess 查询单任务 - 任务完成
func (c *Client) TaskTakeSuccess(tx *gorm.DB, customId string) jobs_gorm_model.Task {
return c.taskTake(tx, customId, TASK_SUCCESS)
func (c *Client) TaskTakeSuccess(ctx context.Context, tx *gorm.DB, customId string) jobs_gorm_model.Task {
return c.taskTake(ctx, tx, customId, TASK_SUCCESS)
}
// TaskTakeError 查询单任务 - 任务异常
func (c *Client) TaskTakeError(tx *gorm.DB, customId string) jobs_gorm_model.Task {
return c.taskTake(tx, customId, TASK_ERROR)
func (c *Client) TaskTakeError(ctx context.Context, tx *gorm.DB, customId string) jobs_gorm_model.Task {
return c.taskTake(ctx, tx, customId, TASK_ERROR)
}
// TaskTakeTimeout 查询单任务 - 任务超时
func (c *Client) TaskTakeTimeout(tx *gorm.DB, customId string) jobs_gorm_model.Task {
return c.taskTake(tx, customId, TASK_TIMEOUT)
func (c *Client) TaskTakeTimeout(ctx context.Context, tx *gorm.DB, customId string) jobs_gorm_model.Task {
return c.taskTake(ctx, tx, customId, TASK_TIMEOUT)
}
// TaskTakeWait 查询单任务 - 任务等待
func (c *Client) TaskTakeWait(tx *gorm.DB, customId string) jobs_gorm_model.Task {
return c.taskTake(tx, customId, TASK_WAIT)
func (c *Client) TaskTakeWait(ctx context.Context, tx *gorm.DB, customId string) jobs_gorm_model.Task {
return c.taskTake(ctx, tx, customId, TASK_WAIT)
}
// TaskTypeTake 查询单任务
func (c *Client) TaskTypeTake(tx *gorm.DB, customId, Type string) (result jobs_gorm_model.Task) {
tx.Where("custom_id = ?", customId).Where("type = ?", Type).Take(&result)
func (c *Client) TaskTypeTake(ctx context.Context, tx *gorm.DB, customId, Type string) (result jobs_gorm_model.Task) {
err := tx.Where("custom_id = ?", customId).Where("type = ?", Type).Take(&result).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("查询单任务:%v", err)
}
return result
}
// 查询单任务
func (c *Client) taskTypeTake(tx *gorm.DB, customId, Type, status string) (result jobs_gorm_model.Task) {
tx.Where("custom_id = ?", customId).Where("type = ?", Type).Where("status = ?", status).Take(&result)
func (c *Client) taskTypeTake(ctx context.Context, tx *gorm.DB, customId, Type, status string) (result jobs_gorm_model.Task) {
err := tx.Where("custom_id = ?", customId).Where("type = ?", Type).Where("status = ?", status).Take(&result).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("查询单任务:%v", err)
}
return result
}
// TaskTypeTakeIn 查询单任务 - 任务运行
func (c *Client) TaskTypeTakeIn(tx *gorm.DB, customId, Type string) jobs_gorm_model.Task {
return c.taskTypeTake(tx, customId, Type, TASK_IN)
func (c *Client) TaskTypeTakeIn(ctx context.Context, tx *gorm.DB, customId, Type string) jobs_gorm_model.Task {
return c.taskTypeTake(ctx, tx, customId, Type, TASK_IN)
}
// TaskTypeTakeSuccess 查询单任务 - 任务完成
func (c *Client) TaskTypeTakeSuccess(tx *gorm.DB, customId, Type string) jobs_gorm_model.Task {
return c.taskTypeTake(tx, customId, Type, TASK_SUCCESS)
func (c *Client) TaskTypeTakeSuccess(ctx context.Context, tx *gorm.DB, customId, Type string) jobs_gorm_model.Task {
return c.taskTypeTake(ctx, tx, customId, Type, TASK_SUCCESS)
}
// TaskTypeTakeError 查询单任务 - 任务异常
func (c *Client) TaskTypeTakeError(tx *gorm.DB, customId, Type string) jobs_gorm_model.Task {
return c.taskTypeTake(tx, customId, Type, TASK_ERROR)
func (c *Client) TaskTypeTakeError(ctx context.Context, tx *gorm.DB, customId, Type string) jobs_gorm_model.Task {
return c.taskTypeTake(ctx, tx, customId, Type, TASK_ERROR)
}
// TaskTypeTakeTimeout 查询单任务 - 任务超时
func (c *Client) TaskTypeTakeTimeout(tx *gorm.DB, customId, Type string) jobs_gorm_model.Task {
return c.taskTypeTake(tx, customId, Type, TASK_TIMEOUT)
func (c *Client) TaskTypeTakeTimeout(ctx context.Context, tx *gorm.DB, customId, Type string) jobs_gorm_model.Task {
return c.taskTypeTake(ctx, tx, customId, Type, TASK_TIMEOUT)
}
// TaskTypeTakeWait 查询单任务 - 任务等待
func (c *Client) TaskTypeTakeWait(tx *gorm.DB, customId, Type string) jobs_gorm_model.Task {
return c.taskTypeTake(tx, customId, Type, TASK_WAIT)
func (c *Client) TaskTypeTakeWait(ctx context.Context, tx *gorm.DB, customId, Type string) jobs_gorm_model.Task {
return c.taskTypeTake(ctx, tx, customId, Type, TASK_WAIT)
}
// TaskFindAll 查询多任务
func (c *Client) TaskFindAll(tx *gorm.DB, frequency int64) (results []jobs_gorm_model.Task) {
tx.Where("frequency = ?", frequency).Order("id asc").Find(&results)
func (c *Client) TaskFindAll(ctx context.Context, tx *gorm.DB, frequency int64) (results []jobs_gorm_model.Task) {
err := tx.Where("frequency = ?", frequency).Order("id asc").Find(&results).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("查询多任务:%v", err)
}
return results
}
// 查询多任务
func (c *Client) taskFindAll(tx *gorm.DB, frequency int64, status string) (results []jobs_gorm_model.Task) {
tx.Where("frequency = ?", frequency).Where("status = ?", status).Order("id asc").Find(&results)
func (c *Client) taskFindAll(ctx context.Context, tx *gorm.DB, frequency int64, status string) (results []jobs_gorm_model.Task) {
err := tx.Where("frequency = ?", frequency).Where("status = ?", status).Order("id asc").Find(&results).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("查询多任务:%v", err)
}
return results
}
// TaskFindAllIn 查询多任务 - 任务运行
func (c *Client) TaskFindAllIn(tx *gorm.DB, frequency int64) []jobs_gorm_model.Task {
return c.taskFindAll(tx, frequency, TASK_IN)
func (c *Client) TaskFindAllIn(ctx context.Context, tx *gorm.DB, frequency int64) []jobs_gorm_model.Task {
return c.taskFindAll(ctx, tx, frequency, TASK_IN)
}
// TaskFindAllSuccess 查询多任务 - 任务完成
func (c *Client) TaskFindAllSuccess(tx *gorm.DB, frequency int64) []jobs_gorm_model.Task {
return c.taskFindAll(tx, frequency, TASK_SUCCESS)
func (c *Client) TaskFindAllSuccess(ctx context.Context, tx *gorm.DB, frequency int64) []jobs_gorm_model.Task {
return c.taskFindAll(ctx, tx, frequency, TASK_SUCCESS)
}
// TaskFindAllError 查询多任务 - 任务异常
func (c *Client) TaskFindAllError(tx *gorm.DB, frequency int64) []jobs_gorm_model.Task {
return c.taskFindAll(tx, frequency, TASK_ERROR)
func (c *Client) TaskFindAllError(ctx context.Context, tx *gorm.DB, frequency int64) []jobs_gorm_model.Task {
return c.taskFindAll(ctx, tx, frequency, TASK_ERROR)
}
// TaskFindAllTimeout 查询多任务 - 任务超时
func (c *Client) TaskFindAllTimeout(tx *gorm.DB, frequency int64) []jobs_gorm_model.Task {
return c.taskFindAll(tx, frequency, TASK_TIMEOUT)
func (c *Client) TaskFindAllTimeout(ctx context.Context, tx *gorm.DB, frequency int64) []jobs_gorm_model.Task {
return c.taskFindAll(ctx, tx, frequency, TASK_TIMEOUT)
}
// TaskFindAllWait 查询多任务 - 任务等待
func (c *Client) TaskFindAllWait(tx *gorm.DB, frequency int64) []jobs_gorm_model.Task {
return c.taskFindAll(tx, frequency, TASK_WAIT)
func (c *Client) TaskFindAllWait(ctx context.Context, tx *gorm.DB, frequency int64) []jobs_gorm_model.Task {
return c.taskFindAll(ctx, tx, frequency, TASK_WAIT)
}
// StartTask 任务启动
func (c *Client) StartTask(tx *gorm.DB, id uint) error {
return c.EditTask(tx, id).
func (c *Client) StartTask(ctx context.Context, tx *gorm.DB, id uint) error {
err := c.EditTask(tx, id).
Select("status", "status_desc").
Updates(jobs_gorm_model.Task{
Status: TASK_IN,
StatusDesc: "启动任务",
}).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("任务启动失败:%v", err)
}
return err
}
// StartTaskCustom 任务启动自定义
func (c *Client) StartTaskCustom(tx *gorm.DB, customId string, customSequence int64) error {
return tx.Model(&jobs_gorm_model.Task{}).
func (c *Client) StartTaskCustom(ctx context.Context, tx *gorm.DB, customId string, customSequence int64) error {
err := tx.Model(&jobs_gorm_model.Task{}).
Where("custom_id = ?", customId).
Where("custom_sequence = ?", customSequence).
Where("status = ?", TASK_WAIT).
@ -145,6 +170,10 @@ func (c *Client) StartTaskCustom(tx *gorm.DB, customId string, customSequence in
Status: TASK_IN,
StatusDesc: "启动任务",
}).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("任务启动自定义失败:%v", err)
}
return err
}
// EditTask 任务修改
@ -153,67 +182,15 @@ func (c *Client) EditTask(tx *gorm.DB, id uint) *gorm.DB {
}
// UpdateFrequency 更新任务频率
func (c *Client) UpdateFrequency(tx *gorm.DB, id uint, frequency int64) *gorm.DB {
return c.EditTask(tx, id).
Select("frequency").
func (c *Client) UpdateFrequency(ctx context.Context, tx *gorm.DB, id uint, frequency int64) error {
err := c.EditTask(tx, id).
Select("frequency", "next_run_time").
Updates(jobs_gorm_model.Task{
Frequency: frequency,
})
}
func (c *Client) taskIpTake(tx *gorm.DB, taskType, ips string) (result jobs_gorm_model.TaskIp) {
tx.Where("task_type = ?", taskType).Where("ips = ?", ips).Take(&result)
return result
}
// TaskIpUpdate 更新ip
func (c *Client) TaskIpUpdate(tx *gorm.DB, taskType, ips string) *gorm.DB {
query := c.taskIpTake(tx, taskType, ips)
if query.Id != 0 {
return tx
}
updateStatus := tx.Create(&jobs_gorm_model.TaskIp{
TaskType: taskType,
Ips: ips,
})
if updateStatus.RowsAffected == 0 {
log.Println("任务更新失败:", updateStatus.Error)
}
return updateStatus
}
// TaskIpInit 实例任务ip
func (c *Client) TaskIpInit(tx *gorm.DB, ips map[string]string) bool {
if c.config.outsideIp == "" || c.config.outsideIp == "0.0.0.0" {
return false
}
tx.Where("ips = ?", c.config.outsideIp).Delete(&jobs_gorm_model.TaskIp{}) // 删除
for k, v := range ips {
if v == "" {
c.TaskIpUpdate(tx, k, c.config.outsideIp)
} else {
find := strings.Contains(v, ",")
if find == true {
// 包含
parts := strings.Split(v, ",")
for _, vv := range parts {
if vv == c.config.outsideIp {
c.TaskIpUpdate(tx, k, c.config.outsideIp)
}
}
} else {
// 不包含
if v == c.config.outsideIp {
c.TaskIpUpdate(tx, k, c.config.outsideIp)
}
}
}
Frequency: frequency,
NextRunTime: gotime.Current().AfterSeconds(frequency).Time,
}).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("更新任务频率失败:%v", err)
}
return true
}
// TaskLogRunTake 查询任务执行日志
func (c *Client) TaskLogRunTake(tx *gorm.DB, taskId uint, runId string) (result jobs_gorm_model.TaskLogRun) {
tx.Select("id", "os", "arch", "outside_ip", "created_at").Where("task_id = ?", taskId).Where("run_id = ?", runId).Take(&result)
return result
return err
}

21
ip.go

@ -1,21 +0,0 @@
package gojobs
import (
"context"
"go.dtapp.net/goip"
"go.dtapp.net/gojobs/jobs_gorm_model"
"gorm.io/gorm"
)
// RefreshIp 刷新Ip
func (c *Client) RefreshIp(ctx context.Context, tx *gorm.DB) {
xip := goip.GetOutsideIp(ctx)
if c.config.outsideIp == "" || c.config.outsideIp == "0.0.0.0" {
return
}
if c.config.outsideIp == xip {
return
}
tx.Where("ips = ?", c.config.outsideIp).Delete(&jobs_gorm_model.TaskIp{}) // 删除
c.config.outsideIp = xip
}

@ -1,5 +1,10 @@
package gojobs
import (
"context"
"go.dtapp.net/gojobs/jobs_gorm_model"
)
const (
TASK_IN = "IN" // 任务运行
TASK_SUCCESS = "SUCCESS" // 任务完成
@ -11,15 +16,15 @@ const (
// Cron
type jobs interface {
// Run 运行
Run(info interface{}, status int, desc string)
// RunAddLog 任务执行日志
RunAddLog(id uint, runId string)
Run(ctx context.Context, info jobs_gorm_model.Task, status int, result string)
// CreateInCustomId 创建正在运行任务
CreateInCustomId()
CreateInCustomId(ctx context.Context, config *ConfigCreateInCustomId) error
// CreateInCustomIdOnly 创建正在运行唯一任务
CreateInCustomIdOnly()
CreateInCustomIdOnly(ctx context.Context, config *ConfigCreateInCustomIdOnly) error
// CreateInCustomIdMaxNumber 创建正在运行任务并限制数量
CreateInCustomIdMaxNumber()
CreateInCustomIdMaxNumber(ctx context.Context, config *ConfigCreateInCustomIdMaxNumber) error
// CreateInCustomIdMaxNumberOnly 创建正在运行唯一任务并限制数量
CreateInCustomIdMaxNumberOnly()
CreateInCustomIdMaxNumberOnly(ctx context.Context, config *ConfigCreateInCustomIdMaxNumberOnly) error
// CreateWaitCustomId 创建正在运行任务
CreateWaitCustomId(ctx context.Context, config *ConfigCreateWaitCustomId) error
}

@ -7,27 +7,27 @@ import (
// Task 任务
type Task struct {
Id uint `gorm:"primaryKey;comment:记录编号" json:"id"` // 记录编号
Status string `gorm:"index;comment:状态码" json:"status"` // 状态码
Params string `gorm:"comment:参数" json:"params"` // 参数
ParamsType string `gorm:"comment:参数类型" json:"params_type"` // 参数类型
StatusDesc string `gorm:"comment:状态描述" json:"status_desc"` // 状态描述
Frequency int64 `gorm:"index;comment:频率(秒单位)" json:"frequency"` // 频率(秒单位)
Number int64 `gorm:"comment:当前次数" json:"number"` // 当前次数
MaxNumber int64 `gorm:"comment:最大次数" json:"max_number"` // 最大次数
RunId string `gorm:"index;comment:执行编号" json:"run_id"` // 执行编号
CustomId string `gorm:"index;comment:自定义编号" json:"custom_id"` // 自定义编号
CustomSequence int64 `gorm:"index;comment:自定义顺序" json:"custom_sequence"` // 自定义顺序
Type string `gorm:"index;comment:类型" json:"type"` // 类型
TypeName string `gorm:"comment:类型名称" json:"type_name"` // 类型名称
CreatedIp string `gorm:"type:inet;default:0.0.0.0;comment:创建外网IP" json:"created_ip"` // 创建外网IP
SpecifyIp string `gorm:"type:inet;default:0.0.0.0;index;comment:指定外网IP" json:"specify_ip"` // 指定外网IP
UpdatedIp string `gorm:"type:inet;default:0.0.0.0;comment:更新外网IP" json:"updated_ip"` // 更新外网IP
Result string `gorm:"comment:结果" json:"result"` // 结果
NextRunTime time.Time `gorm:"comment:下次运行时间" json:"next_run_time"` // 下次运行时间
CreatedAt time.Time `gorm:"autoCreateTime;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt time.Time `gorm:"autoUpdateTime;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"index;comment:删除时间" json:"deleted_at"` // 删除时间
Id uint `gorm:"primaryKey;comment:记录编号" json:"id"` // 记录编号
Status string `gorm:"index;comment:状态码" json:"status"` // 状态码
Params string `gorm:"comment:参数" json:"params"` // 参数
ParamsType string `gorm:"comment:参数类型" json:"params_type"` // 参数类型
StatusDesc string `gorm:"comment:状态描述" json:"status_desc"` // 状态描述
Frequency int64 `gorm:"index;comment:频率(秒单位)" json:"frequency"` // 频率(秒单位)
Number int64 `gorm:"comment:当前次数" json:"number"` // 当前次数
MaxNumber int64 `gorm:"comment:最大次数" json:"max_number"` // 最大次数
RunId string `gorm:"index;comment:执行编号" json:"run_id"` // 执行编号
CustomId string `gorm:"index;comment:自定义编号" json:"custom_id"` // 自定义编号
CustomSequence int64 `gorm:"index;comment:自定义顺序" json:"custom_sequence"` // 自定义顺序
Type string `gorm:"index;comment:类型" json:"type"` // 类型
TypeName string `gorm:"comment:类型名称" json:"type_name"` // 类型名称
CreatedIp string `gorm:"default:0.0.0.0;comment:创建外网IP" json:"created_ip"` // 创建外网IP
SpecifyIp string `gorm:"default:0.0.0.0;index;comment:指定外网IP" json:"specify_ip"` // 指定外网IP
UpdatedIp string `gorm:"default:0.0.0.0;comment:更新外网IP" json:"updated_ip"` // 更新外网IP
Result string `gorm:"comment:结果" json:"result"` // 结果
NextRunTime time.Time `gorm:"comment:下次运行时间" json:"next_run_time"` // 下次运行时间
CreatedAt time.Time `gorm:"autoCreateTime;comment:创建时间" json:"created_at"` // 创建时间
UpdatedAt time.Time `gorm:"autoUpdateTime;comment:更新时间" json:"updated_at"` // 更新时间
DeletedAt gorm.DeletedAt `gorm:"index;comment:删除时间" json:"deleted_at"` // 删除时间
}
func (Task) TableName() string {

@ -1,12 +0,0 @@
package jobs_gorm_model
// TaskIp 任务Ip
type TaskIp struct {
Id int64 `gorm:"primaryKey;comment:记录编号" json:"id"` // 记录编号
TaskType string `gorm:"comment:任务编号" json:"task_type"` // 任务编号
Ips string `gorm:"comment:任务IP" json:"ips"` // 任务IP
}
func (TaskIp) TableName() string {
return "task_ip"
}

@ -4,12 +4,19 @@ import "time"
// TaskLog 任务日志模型
type TaskLog struct {
Id uint `gorm:"primaryKey;comment:记录编号" json:"id"` // 记录编号
TaskId uint `gorm:"index;comment:任务编号" json:"task_id"` // 任务编号
StatusCode int `gorm:"index;comment:状态码" json:"status_code"` // 状态码
Desc string `gorm:"comment:结果" json:"desc"` // 结果
Version string `gorm:"comment:版本" json:"version"` // 版本
CreatedAt time.Time `gorm:"autoCreateTime;comment:创建时间" json:"created_at"` // 创建时间
LogId uint `gorm:"primaryKey;comment:日志编号" json:"log_id"` // 日志编号
TaskId uint `gorm:"index;comment:任务编号" json:"task_id"` // 任务编号
TaskRunId string `gorm:"comment:执行编号" json:"task_run_id"` // 执行编号
TaskResultCode int `gorm:"index;comment:执行状态码" json:"task_result_code"` // 执行状态码
TaskResultDesc string `gorm:"comment:执行结果" json:"task_result_desc"` // 执行结果
SystemHostName string `gorm:"comment:主机名" json:"system_host_name"` // 主机名
SystemInsideIp string `gorm:"default:0.0.0.0;comment:内网ip" json:"system_inside_ip"` // 内网ip
SystemOs string `gorm:"comment:系统类型" json:"system_os"` // 系统类型
SystemArch string `gorm:"comment:系统架构" json:"system_arch"` // 系统架构
GoVersion string `gorm:"comment:go版本" json:"go_version"` // go版本
SdkVersion string `gorm:"comment:sdk版本" json:"sdk_version"` // sdk版本
SystemOutsideIp string `gorm:"default:0.0.0.0;comment:外网ip" json:"system_outside_ip"` // 外网ip
LogTime time.Time `gorm:"autoCreateTime;comment:日志时间" json:"log_time"` // 日志时间
}
func (TaskLog) TableName() string {

@ -1,23 +0,0 @@
package jobs_gorm_model
import "time"
// TaskLogRun 任务执行日志模型
type TaskLogRun struct {
Id uint `gorm:"primaryKey;comment:记录编号" json:"id"` // 记录编号
TaskId uint `gorm:"index;comment:任务编号" json:"task_id"` // 任务编号
RunId string `gorm:"comment:执行编号" json:"run_id"` // 执行编号
OutsideIp string `gorm:"comment:外网ip" json:"outside_ip"` // 外网ip
InsideIp string `gorm:"comment:内网ip" json:"inside_ip"` // 内网ip
Os string `gorm:"comment:系统类型" json:"os"` // 系统类型
Arch string `gorm:"comment:系统架构" json:"arch"` // 系统架构
Gomaxprocs int `gorm:"comment:CPU核数" json:"gomaxprocs"` // CPU核数
GoVersion string `gorm:"comment:GO版本" json:"go_version"` // GO版本
SdkVersion string `gorm:"comment:SDK版本" json:"sdk_version"` // SDK版本
MacAddrs string `gorm:"comment:Mac地址" json:"mac_addrs"` // Mac地址
CreatedAt time.Time `gorm:"autoCreateTime;comment:创建时间" json:"created_at"` // 创建时间
}
func (TaskLogRun) TableName() string {
return "task_log_run"
}

@ -1,34 +0,0 @@
package jobs_mongo_model
import (
"go.mongodb.org/mongo-driver/bson/primitive"
)
// Task 任务
type Task struct {
Id primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` // 记录编号
Status string `json:"status,omitempty" bson:"status,omitempty"` // 状态码
Params string `json:"params,omitempty" bson:"params,omitempty"` // 参数
ParamsType string `json:"params_type,omitempty" bson:"params_type,omitempty"` // 参数类型
StatusDesc string `json:"status_desc,omitempty" bson:"status_desc,omitempty"` // 状态描述
Frequency int64 `json:"frequency,omitempty" bson:"frequency,omitempty"` // 频率(秒单位)
Number int64 `json:"number,omitempty" bson:"number,omitempty"` // 当前次数
MaxNumber int64 `json:"max_number,omitempty" bson:"max_number,omitempty"` // 最大次数
RunId string `json:"run_id,omitempty" bson:"run_id,omitempty"` // 执行编号
CustomId string `json:"custom_id,omitempty" bson:"custom_id,omitempty"` // 自定义编号
CustomSequence int64 `json:"custom_sequence,omitempty" bson:"custom_sequence,omitempty"` // 自定义顺序
Type string `json:"type,omitempty" bson:"type,omitempty"` // 类型
TypeName string `json:"type_name,omitempty" bson:"type_name,omitempty"` // 类型名称
CreatedIp string `json:"created_ip,omitempty" bson:"created_ip,omitempty"` // 创建外网IP
SpecifyIp string `json:"specify_ip,omitempty" bson:"specify_ip,omitempty"` // 指定外网IP
UpdatedIp string `json:"updated_ip,omitempty" bson:"updated_ip,omitempty"` // 更新外网IP
Result string `json:"result,omitempty" bson:"result,omitempty"` // 结果
NextRunTime primitive.DateTime `json:"next_run_time,omitempty" bson:"next_run_time,omitempty"` // 下次运行时间
CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty"` // 创建时间
UpdatedAt primitive.DateTime `json:"updated_at,omitempty" bson:"updated_at,omitempty"` // 更新时间
DeletedAt primitive.DateTime `json:"deleted_at,omitempty" bson:"deleted_at,omitempty"` // 删除时间
}
func (Task) TableName() string {
return "task"
}

@ -1,14 +0,0 @@
package jobs_mongo_model
import "go.mongodb.org/mongo-driver/bson/primitive"
// TaskIp 任务Ip
type TaskIp struct {
Id primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` // 记录编号
TaskType string `json:"task_type,omitempty" bson:"task_type,omitempty"` // 任务编号
Ips string `json:"ips,omitempty" bson:"ips,omitempty"` // 任务IP
}
func (TaskIp) TableName() string {
return "task_ip"
}

@ -1,52 +0,0 @@
package jobs_mongo_model
import (
"go.dtapp.net/dorm"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type TaskIssueRecordTaskInfo struct {
Id uint `json:"id,omitempty" bson:"id,omitempty"` // 记录编号
Status string `json:"status,omitempty" bson:"status,omitempty"` // 状态码
Params string `json:"params,omitempty" bson:"params,omitempty"` // 参数
ParamsType string `json:"params_type,omitempty" bson:"params_type,omitempty"` // 参数类型
StatusDesc string `json:"status_desc,omitempty" bson:"status_desc,omitempty"` // 状态描述
Frequency int64 `json:"frequency,omitempty" bson:"frequency,omitempty"` // 频率(秒单位)
Number int64 `json:"number,omitempty" bson:"number,omitempty"` // 当前次数
MaxNumber int64 `json:"max_number,omitempty" bson:"max_number,omitempty"` // 最大次数
RunId string `json:"run_id,omitempty" bson:"run_id,omitempty"` // 执行编号
CustomId string `json:"custom_id,omitempty" bson:"custom_id,omitempty"` // 自定义编号
CustomSequence int64 `json:"custom_sequence,omitempty" bson:"custom_sequence,omitempty"` // 自定义顺序
Type string `json:"type,omitempty" bson:"type,omitempty"` // 类型
TypeName string `json:"type_name,omitempty" bson:"type_name,omitempty"` // 类型名称
CreatedIp string `json:"created_ip,omitempty" bson:"created_ip,omitempty"` // 创建外网IP
SpecifyIp string `json:"specify_ip,omitempty" bson:"specify_ip,omitempty"` // 指定外网IP
UpdatedIp string `json:"updated_ip,omitempty" bson:"updated_ip,omitempty"` // 更新外网IP
Result string `json:"result,omitempty" bson:"result,omitempty"` // 结果
NextRunTime dorm.BsonTime `json:"next_run_time,omitempty" bson:"next_run_time,omitempty"` // 下次运行时间
CreatedAt dorm.BsonTime `json:"created_at,omitempty" bson:"created_at,omitempty"` // 创建时间
UpdatedAt dorm.BsonTime `json:"updated_at,omitempty" bson:"updated_at,omitempty"` // 更新时间
}
type TaskIssueRecordSystemInfo struct {
OutsideIp string `json:"outside_ip,omitempty" bson:"outside_ip,omitempty"` // 外网ip
InsideIp string `json:"inside_ip,omitempty" bson:"inside_ip,omitempty"` // 内网ip
Os string `json:"os,omitempty" bson:"os,omitempty"` // 系统类型
Arch string `json:"arch,omitempty" bson:"arch,omitempty"` // 系统架构
Gomaxprocs int `json:"gomaxprocs,omitempty" bson:"gomaxprocs,omitempty"` // CPU核数
GoVersion string `json:"go_version,omitempty" bson:"go_version,omitempty"` // GO版本
SdkVersion string `json:"sdk_version,omitempty" bson:"sdk_version,omitempty"` // SDK版本
}
// TaskIssueRecord 任务发布记录
type TaskIssueRecord struct {
Id primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` // 记录编号
TaskInfo TaskIssueRecordTaskInfo `json:"task_info,omitempty" bson:"task_info,omitempty"` // 任务信息
SystemInfo TaskIssueRecordSystemInfo `json:"system_info,omitempty" bson:"system_info,omitempty"` // 系统信息
RecordAddress string `json:"record_address,omitempty" bson:"record_address,omitempty"` // 接收地址
RecordTime primitive.DateTime `json:"record_time,omitempty" bson:"record_time,omitempty"` // 记录时间
}
func (TaskIssueRecord) TableName() string {
return "task_issue_record"
}

@ -1,19 +0,0 @@
package jobs_mongo_model
import (
"go.mongodb.org/mongo-driver/bson/primitive"
)
// TaskLog 任务日志模型
type TaskLog struct {
Id primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` // 记录编号
TaskId uint `json:"task_id,omitempty" bson:"task_id,omitempty"` // 任务编号
StatusCode int `json:"status_code,omitempty" bson:"status_code,omitempty"` // 状态码
Desc string `json:"desc,omitempty" bson:"desc,omitempty"` // 结果
Version string `json:"version,omitempty" bson:"version,omitempty"` // 版本
CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty"` // 创建时间
}
func (TaskLog) TableName() string {
return "task_log"
}

@ -1,25 +0,0 @@
package jobs_mongo_model
import (
"go.mongodb.org/mongo-driver/bson/primitive"
)
// TaskLogRun 任务执行日志模型
type TaskLogRun struct {
Id primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` // 记录编号
TaskId uint `json:"task_id,omitempty" bson:"task_id,omitempty"` // 任务编号
RunId string `json:"run_id,omitempty" bson:"run_id,omitempty"` // 执行编号
OutsideIp string `json:"outside_ip,omitempty" bson:"outside_ip,omitempty"` // 外网ip
InsideIp string `json:"inside_ip,omitempty" bson:"inside_ip,omitempty"` // 内网ip
Os string `json:"os,omitempty" bson:"os,omitempty"` // 系统类型
Arch string `json:"arch,omitempty" bson:"arch,omitempty"` // 系统架构
Gomaxprocs int `json:"gomaxprocs,omitempty" bson:"gomaxprocs,omitempty"` // CPU核数
GoVersion string `json:"go_version,omitempty" bson:"go_version,omitempty"` // GO版本
SdkVersion string `json:"sdk_version,omitempty" bson:"sdk_version,omitempty"` // SDK版本
MacAddrs string `json:"mac_addrs,omitempty" bson:"mac_addrs,omitempty"` // Mac地址
CreatedAt primitive.DateTime `json:"created_at,omitempty" bson:"created_at,omitempty"` // 创建时间
}
func (TaskLogRun) TableName() string {
return "task_log_run"
}

@ -1,17 +0,0 @@
package jobs_mongo_model
import (
"go.mongodb.org/mongo-driver/bson/primitive"
)
// TaskReceiveRecord 任务接收记录
type TaskReceiveRecord struct {
Id primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"` // 记录编号
TaskInfo TaskIssueRecordTaskInfo `json:"task_info,omitempty" bson:"task_info,omitempty"` // 任务信息
SystemInfo TaskIssueRecordSystemInfo `json:"system_info,omitempty" bson:"system_info,omitempty"` // 系统信息
RecordTime primitive.DateTime `json:"record_time,omitempty" bson:"record_time,omitempty"` // 记录时间
}
func (TaskReceiveRecord) TableName() string {
return "task_receive_record_"
}

@ -1,31 +0,0 @@
package jobs_xorm_model
import "time"
// Task 任务
type Task struct {
Id uint `xorm:"pk autoincr" json:"id"` // 记录编号
Status string `json:"status"` // 状态码
Params string `json:"params"` // 参数
ParamsType string `json:"params_type"` // 参数类型
StatusDesc string `json:"status_desc"` // 状态描述
Frequency int64 `json:"frequency"` // 频率(秒单位)
Number int64 `json:"number"` // 当前次数
MaxNumber int64 `json:"max_number"` // 最大次数
RunId string `json:"run_id"` // 执行编号
CustomId string `json:"custom_id"` // 自定义编号
CustomSequence int64 `json:"custom_sequence"` // 自定义顺序
Type string `json:"type"` // 类型
CreatedIp string `json:"created_ip"` // 创建外网IP
SpecifyIp string `json:"specify_ip"` // 指定外网IP
UpdatedIp string `json:"updated_ip"` // 更新外网IP
Result string `json:"result"` // 结果
NextRunTime time.Time `json:"next_run_time"` // 下次运行时间
CreatedAt string `xorm:"created" json:"created_at"` // 创建时间
UpdatedAt string `xorm:"created" json:"updated_at"` // 更新时间
DeletedAt string `xorm:"deleted" json:"deleted_at"` // 删除时间
}
func (Task) TableName() string {
return "task"
}

@ -1,12 +0,0 @@
package jobs_xorm_model
// TaskIp 任务Ip
type TaskIp struct {
Id int64 `xorm:"pk autoincr" json:"id"`
TaskType string `json:"task_type"` // 任务编号
Ips string `json:"ips"` // 任务IP
}
func (TaskIp) TableName() string {
return "task_ip"
}

@ -1,15 +0,0 @@
package jobs_xorm_model
// TaskLog 任务日志模型
type TaskLog struct {
Id uint `xorm:"pk autoincr" json:"id"` // 记录编号
TaskId uint `json:"task_id"` // 任务编号
StatusCode int `json:"status_code"` // 状态码
Desc string `json:"desc"` // 结果
Version int `json:"version"` // 版本
CreatedAt string `xorm:"created" json:"created_at"` // 创建时间
}
func (TaskLog) TableName() string {
return "task_log"
}

@ -1,21 +0,0 @@
package jobs_xorm_model
// TaskLogRun 任务执行日志模型
type TaskLogRun struct {
Id uint `xorm:"pk autoincr" json:"id"` // 记录编号
TaskId uint `json:"task_id"` // 任务编号
RunId string `json:"run_id"` // 执行编号
OutsideIp string `json:"outside_ip"` // 外网ip
InsideIp string `json:"inside_ip"` // 内网ip
Os string `json:"os"` // 系统类型
Arch string `json:"arch"` // 系统架构
Gomaxprocs int `json:"gomaxprocs"` // CPU核数
GoVersion string `json:"go_version"` // GO版本
SdkVersion string `json:"sdk_version"` // SDK版本
MacAddrs string `json:"mac_addrs"` // Mac地址
CreatedAt string `xorm:"created" json:"created_at"` // 创建时间
}
func (TaskLogRun) TableName() string {
return "task_log_run"
}

@ -10,7 +10,7 @@ import (
// Lock 上锁
func (c *Client) Lock(ctx context.Context, info jobs_gorm_model.Task, id any) (string, error) {
return c.cache.redisLockClient.Lock(ctx, fmt.Sprintf("%s%s%v%s%v", c.cache.lockKeyPrefix, c.cache.lockKeySeparator, info.Type, c.cache.lockKeySeparator, id), fmt.Sprintf("已在%s@%s机器上锁成功%v", c.config.insideIp, c.config.outsideIp, gotime.Current().Format()), time.Duration(info.Frequency)*3*time.Second)
return c.cache.redisLockClient.Lock(ctx, fmt.Sprintf("%s%s%v%s%v", c.cache.lockKeyPrefix, c.cache.lockKeySeparator, info.Type, c.cache.lockKeySeparator, id), fmt.Sprintf("[Lock] 已在%s@%s机器上锁成功时间:%v", c.config.systemInsideIp, c.config.systemOutsideIp, gotime.Current().Format()), time.Duration(info.Frequency)*3*time.Second)
}
// Unlock Lock 解锁
@ -20,5 +20,5 @@ func (c *Client) Unlock(ctx context.Context, info jobs_gorm_model.Task, id any)
// LockForever 永远上锁
func (c *Client) LockForever(ctx context.Context, info jobs_gorm_model.Task, id any) (string, error) {
return c.cache.redisLockClient.LockForever(ctx, fmt.Sprintf("%s%s%v%s%v", c.cache.lockKeyPrefix, c.cache.lockKeySeparator, info.Type, c.cache.lockKeySeparator, id), fmt.Sprintf("已在%s@%s机器永远上锁成功%v", c.config.insideIp, c.config.outsideIp, gotime.Current().Format()))
return c.cache.redisLockClient.LockForever(ctx, fmt.Sprintf("%s%s%v%s%v", c.cache.lockKeyPrefix, c.cache.lockKeySeparator, info.Type, c.cache.lockKeySeparator, id), fmt.Sprintf("[LockForever] 已在%s@%s机器永远上锁成功时间:%v", c.config.systemInsideIp, c.config.systemOutsideIp, gotime.Current().Format()))
}

@ -0,0 +1,24 @@
package gojobs
import (
"context"
"fmt"
"go.dtapp.net/gojobs/jobs_gorm_model"
"go.dtapp.net/gotime"
"time"
)
// LockCustomId 上锁
func (c *Client) LockCustomId(ctx context.Context, info jobs_gorm_model.Task) (string, error) {
return c.cache.redisLockClient.Lock(ctx, fmt.Sprintf("%s%s%v%s%v", c.cache.lockKeyPrefix, c.cache.lockKeySeparator, info.Type, c.cache.lockKeySeparator, info.CustomId), fmt.Sprintf("[LockCustomId] 已在%s@%s机器上锁成功时间%v", c.config.systemInsideIp, c.config.systemOutsideIp, gotime.Current().Format()), time.Duration(info.Frequency)*3*time.Second)
}
// UnlockCustomId 解锁
func (c *Client) UnlockCustomId(ctx context.Context, info jobs_gorm_model.Task) error {
return c.cache.redisLockClient.Unlock(ctx, fmt.Sprintf("%s%s%v%s%v", c.cache.lockKeyPrefix, c.cache.lockKeySeparator, info.Type, c.cache.lockKeySeparator, info.CustomId))
}
// LockForeverCustomId 永远上锁
func (c *Client) LockForeverCustomId(ctx context.Context, info jobs_gorm_model.Task) (string, error) {
return c.cache.redisLockClient.LockForever(ctx, fmt.Sprintf("%s%s%v%s%v", c.cache.lockKeyPrefix, c.cache.lockKeySeparator, info.Type, c.cache.lockKeySeparator, info.CustomId), fmt.Sprintf("[LockCustomId] 已在%s@%s机器永远上锁成功时间%v", c.config.systemInsideIp, c.config.systemOutsideIp, gotime.Current().Format()))
}

@ -10,15 +10,15 @@ import (
// LockId 上锁
func (c *Client) LockId(ctx context.Context, info jobs_gorm_model.Task) (string, error) {
return c.cache.redisLockClient.Lock(ctx, fmt.Sprintf("%s%s%v%s%v", c.cache.lockKeyPrefix, c.cache.lockKeySeparator, info.Type, c.cache.lockKeySeparator, info.Id), fmt.Sprintf("已在%s@%s机器上锁成功%v", c.config.insideIp, c.config.outsideIp, gotime.Current().Format()), time.Duration(info.Frequency)*3*time.Second)
return c.cache.redisLockClient.Lock(ctx, fmt.Sprintf("%s%s%v%s%v", c.cache.lockKeyPrefix, c.cache.lockKeySeparator, info.Type, c.cache.lockKeySeparator, info.Id), fmt.Sprintf("[LockId] 已在%s@%s机器上锁成功时间:%v", c.config.systemInsideIp, c.config.systemOutsideIp, gotime.Current().Format()), time.Duration(info.Frequency)*3*time.Second)
}
// UnlockId Lock 解锁
// UnlockId 解锁
func (c *Client) UnlockId(ctx context.Context, info jobs_gorm_model.Task) error {
return c.cache.redisLockClient.Unlock(ctx, fmt.Sprintf("%s%s%v%s%v", c.cache.lockKeyPrefix, c.cache.lockKeySeparator, info.Type, c.cache.lockKeySeparator, info.Id))
}
// LockForeverId 永远上锁
func (c *Client) LockForeverId(ctx context.Context, info jobs_gorm_model.Task) (string, error) {
return c.cache.redisLockClient.LockForever(ctx, fmt.Sprintf("%s%s%v%s%v", c.cache.lockKeyPrefix, c.cache.lockKeySeparator, info.Type, c.cache.lockKeySeparator, info.Id), fmt.Sprintf("已在%s@%s机器永远上锁成功%v", c.config.insideIp, c.config.outsideIp, gotime.Current().Format()))
return c.cache.redisLockClient.LockForever(ctx, fmt.Sprintf("%s%s%v%s%v", c.cache.lockKeyPrefix, c.cache.lockKeySeparator, info.Type, c.cache.lockKeySeparator, info.Id), fmt.Sprintf("[LockForeverId] 已在%s@%s机器永远上锁成功时间:%v", c.config.systemInsideIp, c.config.systemOutsideIp, gotime.Current().Format()))
}

@ -3,165 +3,64 @@ package gojobs
import (
"context"
"go.dtapp.net/gojobs/jobs_gorm_model"
"go.dtapp.net/gojobs/jobs_mongo_model"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.dtapp.net/gotime"
"go.dtapp.net/gotrace_id"
)
// 创建模型
func (c *Client) autoMigrateTask() {
c.zapLog.WithLogger().Sugar().Info(c.db.gormClient.Db.AutoMigrate(&jobs_gorm_model.Task{}))
}
// 创建模型
func (c *Client) autoMigrateTaskIp() {
c.zapLog.WithLogger().Sugar().Info(c.db.gormClient.Db.AutoMigrate(&jobs_gorm_model.TaskIp{}))
}
// 创建模型
func (c *Client) autoMigrateTaskLog() {
c.zapLog.WithLogger().Sugar().Info(c.db.gormClient.Db.AutoMigrate(&jobs_gorm_model.TaskLog{}))
func (c *Client) autoMigrateTask(ctx context.Context) {
err := c.gormClient.GetDb().AutoMigrate(&jobs_gorm_model.Task{})
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("创建模型:%s", err)
}
}
// 创建模型
func (c *Client) autoMigrateTaskLogRun() {
c.zapLog.WithLogger().Sugar().Info(c.db.gormClient.Db.AutoMigrate(&jobs_gorm_model.TaskLogRun{}))
}
// 创建时间序列集合
func (c *Client) mongoCreateCollectionTask(ctx context.Context) {
var commandResult bson.M
commandErr := c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).RunCommand(ctx, bson.D{{
"listCollections", 1,
}}).Decode(&commandResult)
if commandErr != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("检查时间序列集合:%s", commandErr)
} else {
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).CreateCollection(ctx, jobs_mongo_model.Task{}.TableName(), options.CreateCollection().SetTimeSeriesOptions(options.TimeSeries().SetTimeField("created_at"))))
func (c *Client) autoMigrateTaskLog(ctx context.Context) {
err := c.gormClient.GetDb().AutoMigrate(&jobs_gorm_model.TaskLog{})
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("创建模型:%s", err)
}
}
// 创建索引
func (c *Client) mongoCreateIndexesTask(ctx context.Context) {
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.Task{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"status", 1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.Task{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"frequency", 1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.Task{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"custom_id", 1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.Task{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"type", 1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.Task{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"created_ip", 1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.Task{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"specify_ip", 1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.Task{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"updated_ip", 1},
}}))
}
// 创建索引
func (c *Client) mongoCreateIndexesTaskIp(ctx context.Context) {
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.TaskIp{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"task_type", 1},
}}))
}
// 创建时间序列集合
func (c *Client) mongoCreateCollectionTaskLog(ctx context.Context) {
var commandResult bson.M
commandErr := c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).RunCommand(ctx, bson.D{{
"listCollections", 1,
}}).Decode(&commandResult)
if commandErr != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("检查时间序列集合:%s", commandErr)
} else {
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).CreateCollection(ctx, jobs_mongo_model.TaskLog{}.TableName(), options.CreateCollection().SetTimeSeriesOptions(options.TimeSeries().SetTimeField("created_at"))))
// GormTaskLogDelete 删除
func (c *Client) GormTaskLogDelete(ctx context.Context, hour int64) error {
err := c.gormClient.GetDb().Where("log_time < ?", gotime.Current().BeforeHour(hour).Format()).Delete(&jobs_gorm_model.TaskLog{}).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("删除失败:%s", err)
}
return err
}
// 创建索引
func (c *Client) mongoCreateIndexesTaskLog(ctx context.Context) {
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.TaskLog{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"task_id", -1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.TaskLog{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"status_code", -1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.TaskLog{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"version", -1},
}}))
}
// 创建时间序列集合
func (c *Client) mongoCreateCollectionTaskLogRun(ctx context.Context) {
var commandResult bson.M
commandErr := c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).RunCommand(ctx, bson.D{{
"listCollections", 1,
}}).Decode(&commandResult)
if commandErr != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("检查时间序列集合:%s", commandErr)
} else {
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).CreateCollection(ctx, jobs_mongo_model.TaskLogRun{}.TableName(), options.CreateCollection().SetTimeSeriesOptions(options.TimeSeries().SetTimeField("created_at"))))
// TaskLogRecord 记录
func (c *Client) TaskLogRecord(ctx context.Context, task jobs_gorm_model.Task, taskResultCode int, taskResultDesc string) {
runId := gotrace_id.GetTraceIdContext(ctx)
c.GormTaskLogRecord(ctx, task, runId, taskResultCode, taskResultDesc)
if c.mongoConfig.stats {
c.MongoTaskLogRecord(ctx, task, runId, taskResultCode, taskResultDesc)
}
}
// 创建索引
func (c *Client) mongoCreateIndexesTaskLogRun(ctx context.Context) {
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.TaskLog{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"task_id", -1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.TaskLog{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"run_id", -1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.TaskLog{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"outside_ip", -1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.TaskLog{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"inside_ip", -1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.TaskLog{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"os", -1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.TaskLog{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"arch", -1},
}}))
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).Collection(jobs_mongo_model.TaskLog{}.TableName()).Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{
{"go_version", -1},
}}))
}
// GormTaskLogRecord 记录
func (c *Client) GormTaskLogRecord(ctx context.Context, task jobs_gorm_model.Task, runId string, taskResultCode int, taskResultDesc string) {
// 创建时间序列集合
func (c *Client) mongoCreateCollectionTaskIssueRecord(ctx context.Context) {
var commandResult bson.M
commandErr := c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).RunCommand(ctx, bson.D{{
"listCollections", 1,
}}).Decode(&commandResult)
if commandErr != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("检查时间序列集合:%s", commandErr)
} else {
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).CreateCollection(ctx, jobs_mongo_model.TaskIssueRecord{}.TableName(), options.CreateCollection().SetTimeSeriesOptions(options.TimeSeries().SetTimeField("record_time"))))
taskLog := jobs_gorm_model.TaskLog{
TaskId: task.Id,
TaskRunId: runId,
TaskResultCode: taskResultCode,
TaskResultDesc: taskResultDesc,
SystemHostName: c.config.systemHostname,
SystemInsideIp: c.config.systemInsideIp,
SystemOs: c.config.systemOs,
SystemArch: c.config.systemKernel,
GoVersion: c.config.goVersion,
SdkVersion: c.config.sdkVersion,
SystemOutsideIp: c.config.systemOutsideIp,
}
}
// 创建时间序列集合
func (c *Client) mongoCreateCollectionTaskReceiveRecord(ctx context.Context) {
if c.cache.cornKeyCustom != "" {
var commandResult bson.M
commandErr := c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).RunCommand(ctx, bson.D{{
"listCollections", 1,
}}).Decode(&commandResult)
if commandErr != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("检查时间序列集合:%s", commandErr)
} else {
c.zapLog.WithTraceId(ctx).Sugar().Info(c.db.mongoClient.Db.Database(c.db.mongoDatabaseName).CreateCollection(ctx, jobs_mongo_model.TaskReceiveRecord{}.TableName()+c.cache.cornKeyCustom, options.CreateCollection().SetTimeSeriesOptions(options.TimeSeries().SetTimeField("record_time"))))
}
err := c.gormClient.GetDb().Create(&taskLog).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("记录失败:%s", err)
c.zapLog.WithTraceId(ctx).Sugar().Errorf("记录数据:%+v", taskLog)
}
}

@ -0,0 +1,118 @@
package gojobs
import (
"context"
"go.dtapp.net/dorm"
"go.dtapp.net/gojobs/jobs_gorm_model"
"go.dtapp.net/golog"
"go.dtapp.net/gotime"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
// TaskLog 任务日志模型
type TaskLog struct {
LogId primitive.ObjectID `json:"log_id,omitempty" bson:"_id,omitempty"` //【记录】编号
LogTime primitive.DateTime `json:"log_time,omitempty" bson:"log_time"` //【记录】时间
Task struct {
Id uint `json:"id" bson:"id"` //【任务】编号
RunId string `json:"run_id" bson:"run_id"` //【任务】执行编号
ResultCode int `json:"result_code" bson:"result_code"` //【任务】执行状态码
ResultDesc string `json:"result_desc" bson:"result_desc"` //【任务】执行结果
ResultTime string `json:"result_time" bson:"result_time"` //【任务】执行时间
} `json:"task,omitempty" bson:"task,omitempty"` //【任务】信息
System struct {
Hostname string `json:"hostname" bson:"hostname"` //【系统】主机名
Os string `json:"os" bson:"os"` //【系统】系统类型
Version string `json:"version" bson:"version"` //【系统】系统版本
Kernel string `json:"kernel" bson:"kernel"` //【系统】系统内核
KernelVersion string `json:"kernel_version" bson:"kernel_version"` //【系统】系统内核版本
BootTime string `json:"boot_time" bson:"boot_time"` //【系统】系统开机时间
CpuCores int `json:"cpu_cores,omitempty" bson:"cpu_cores,omitempty"` //【系统】CPU核数
CpuModelName string `json:"cpu_model_name,omitempty" bson:"cpu_model_name,omitempty"` //【系统】CPU型号名称
CpuMhz float64 `json:"cpu_mhz,omitempty" bson:"cpu_mhz,omitempty"` //【系统】CPU兆赫
InsideIp string `json:"inside_ip" bson:"inside_ip"` //【系统】内网ip
OutsideIp string `json:"outside_ip" bson:"outside_ip"` //【系统】外网ip
GoVersion string `json:"go_version,omitempty" bson:"go_version,omitempty"` //【系统】go版本
SdkVersion string `json:"sdk_version,omitempty" bson:"sdk_version,omitempty"` //【系统】sdk版本
MongoVersion string `json:"mongo_version,omitempty" bson:"mongo_version,omitempty"` //【系统】mongo版本
MongoSdkVersion string `json:"mongo_sdk_version,omitempty" bson:"mongo_sdk_version,omitempty"` //【系统】mongo sdk版本
RedisVersion string `json:"redis_version,omitempty" bson:"redis_version,omitempty"` //【系统】redis版本
RedisSdkVersion string `json:"redis_sdk_version,omitempty" bson:"redis_sdk_version,omitempty"` //【系统】redis sdk版本
LogVersion string `json:"log_version,omitempty" bson:"log_version,omitempty"` //【系统】log版本
} `json:"system,omitempty" bson:"system,omitempty"` //【系统】信息
}
func (TaskLog) CollectionName() string {
return "task_log"
}
// 创建时间序列集合
func (TaskLog) createCollection(ctx context.Context, zapLog *golog.ZapLog, db *dorm.MongoClient, databaseName string) {
err := db.Database(databaseName).CreateCollection(ctx, TaskLog{}.CollectionName(), options.CreateCollection().SetTimeSeriesOptions(options.TimeSeries().SetTimeField("log_time")))
if err != nil {
zapLog.WithTraceId(ctx).Sugar().Errorf("创建时间序列集合:%s", err)
}
}
// 创建索引
func (TaskLog) createIndexes(ctx context.Context, zapLog *golog.ZapLog, db *dorm.MongoClient, databaseName string) {
_, err := db.Database(databaseName).Collection(TaskLog{}.CollectionName()).CreateManyIndexes(ctx, []mongo.IndexModel{{
Keys: bson.D{{
Key: "log_time",
Value: -1,
}},
}})
if err != nil {
zapLog.WithTraceId(ctx).Sugar().Errorf("创建索引:%s", err)
}
}
// MongoTaskLogRecord 记录
func (c *Client) MongoTaskLogRecord(ctx context.Context, task jobs_gorm_model.Task, runId string, taskResultCode int, taskResultDesc string) {
taskLog := TaskLog{
LogId: primitive.NewObjectID(),
LogTime: primitive.NewDateTimeFromTime(gotime.Current().Time),
}
taskLog.Task.Id = task.Id
taskLog.Task.RunId = runId
taskLog.Task.ResultCode = taskResultCode
taskLog.Task.ResultDesc = taskResultDesc
taskLog.Task.ResultTime = gotime.Current().Format()
taskLog.System.Hostname = c.config.systemHostname //【系统】主机名
taskLog.System.Os = c.config.systemOs //【系统】系统类型
taskLog.System.Version = c.config.systemVersion //【系统】系统版本
taskLog.System.Kernel = c.config.systemKernel //【系统】系统内核
taskLog.System.KernelVersion = c.config.systemKernelVersion //【系统】系统内核版本
taskLog.System.BootTime = gotime.SetCurrent(gotime.SetCurrentUnix(int64(c.config.systemBootTime)).Time).Format() //【系统】系统开机时间
taskLog.System.CpuCores = c.config.cpuCores //【系统】CPU核数
taskLog.System.CpuModelName = c.config.cpuModelName //【程序】CPU型号名称
taskLog.System.CpuMhz = c.config.cpuMhz //【系统】CPU兆赫
taskLog.System.InsideIp = c.config.systemInsideIp //【系统】内网ip
taskLog.System.OutsideIp = c.config.systemOutsideIp //【系统】外网ip
taskLog.System.GoVersion = c.config.goVersion //【系统】Go版本
taskLog.System.SdkVersion = c.config.sdkVersion //【系统】Sdk版本
taskLog.System.MongoVersion = c.config.mongoVersion //【系统】mongo版本
taskLog.System.MongoSdkVersion = c.config.mongoSdkVersion //【系统】mongo sdk版本
taskLog.System.RedisVersion = c.config.redisVersion //【系统】redis版本
taskLog.System.RedisSdkVersion = c.config.redisSdkVersion //【系统】redis sdk版本
taskLog.System.LogVersion = c.config.logVersion //【系统】log版本
_, err := c.mongoClient.Database(c.mongoConfig.databaseName).Collection(TaskLog{}.CollectionName()).InsertOne(ctx, taskLog)
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("记录失败:%s", err)
c.zapLog.WithTraceId(ctx).Sugar().Errorf("记录数据:%+v", taskLog)
}
}
// MongoTaskLogDelete 删除
func (c *Client) MongoTaskLogDelete(ctx context.Context, hour int64) (*mongo.DeleteResult, error) {
filter := bson.D{{"log_time", bson.D{{"$lt", primitive.NewDateTimeFromTime(gotime.Current().BeforeHour(hour).Time)}}}}
return c.mongoClient.Database(c.mongoConfig.databaseName).Collection(TaskLog{}.CollectionName()).DeleteMany(ctx, filter)
}

@ -1,55 +0,0 @@
package gojobs
import (
"context"
"go.dtapp.net/dorm"
"go.dtapp.net/gojobs/jobs_gorm_model"
"go.dtapp.net/gojobs/jobs_mongo_model"
"go.dtapp.net/gotime"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// PublishLog 发布记录
func (c *Client) PublishLog(ctx context.Context, info jobs_gorm_model.Task, recordAddress string) {
_, err := c.db.mongoClient.Database(c.db.mongoDatabaseName).
Collection(jobs_mongo_model.TaskIssueRecord{}.TableName()).
InsertOne(&jobs_mongo_model.TaskIssueRecord{
Id: primitive.NewObjectID(),
TaskInfo: jobs_mongo_model.TaskIssueRecordTaskInfo{
Id: info.Id,
Status: info.Status,
Params: info.Params,
ParamsType: info.ParamsType,
StatusDesc: info.StatusDesc,
Frequency: info.Frequency,
Number: info.Number,
MaxNumber: info.MaxNumber,
RunId: info.RunId,
CustomId: info.CustomId,
CustomSequence: info.CustomSequence,
Type: info.Type,
TypeName: info.TypeName,
CreatedIp: info.CreatedIp,
SpecifyIp: info.SpecifyIp,
UpdatedIp: info.UpdatedIp,
Result: info.Result,
NextRunTime: dorm.BsonTime(info.NextRunTime),
CreatedAt: dorm.BsonTime(info.CreatedAt),
UpdatedAt: dorm.BsonTime(info.UpdatedAt),
},
SystemInfo: jobs_mongo_model.TaskIssueRecordSystemInfo{
InsideIp: c.config.insideIp,
OutsideIp: c.config.outsideIp,
Os: c.config.os,
Arch: c.config.arch,
Gomaxprocs: c.config.maxProCs,
GoVersion: c.config.version,
SdkVersion: c.config.runVersion,
},
RecordAddress: recordAddress,
RecordTime: primitive.NewDateTimeFromTime(gotime.Current().Time),
})
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.RunAddLog.jobs_mongo_model.TaskIssueRecord]%s", err.Error())
}
}

@ -11,8 +11,8 @@ import (
// message 消息
func (c *Client) Publish(ctx context.Context, channel string, message interface{}) error {
publish, err := c.cache.redisClient.Publish(ctx, channel, message).Result()
if c.config.debug == true {
c.zapLog.WithTraceId(ctx).Sugar().Info("[jobs.Publish] %s %s %v %s\n", channel, message, publish, err)
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("发布失败:%s %s %v %s\n", channel, message, publish, err)
}
return err
}

@ -4,9 +4,9 @@ import (
"context"
"errors"
"fmt"
"go.dtapp.net/goip"
"go.dtapp.net/gojobs/jobs_gorm_model"
"go.dtapp.net/gostring"
"go.dtapp.net/gotrace_id"
"math/rand"
"time"
)
@ -21,9 +21,12 @@ func (c *Client) GetIssueAddress(ctx context.Context, workers []string, v *jobs_
var (
currentIp = "" // 当前Ip
appointIpStatus = false // 指定Ip状态
traceId = gotrace_id.GetTraceIdContext(ctx)
)
if v.SpecifyIp != "" {
v.SpecifyIp = goip.IsIp(v.SpecifyIp)
}
// 赋值ip
if v.SpecifyIp != "" && v.SpecifyIp != SpecifyIpNull {
currentIp = v.SpecifyIp
@ -32,10 +35,10 @@ func (c *Client) GetIssueAddress(ctx context.Context, workers []string, v *jobs_
// 只有一个客户端在线
if len(workers) == 1 {
if appointIpStatus == true {
if appointIpStatus {
// 判断是否指定某ip执行
if gostring.Contains(workers[0], currentIp) == true {
c.zapLog.WithTraceId(ctx).Sugar().Info("[jobs.GetIssueAddress]只有一个客户端在线指定某ip执行", traceId, workers[0], currentIp)
if gostring.Contains(workers[0], currentIp) {
c.zapLog.WithTraceId(ctx).Sugar().Info("只有一个客户端在线指定某ip执行", workers[0], currentIp)
return workers[0], nil
}
return "", errors.New(fmt.Sprintf("需要执行的[%s]客户端不在线", currentIp))
@ -44,10 +47,10 @@ func (c *Client) GetIssueAddress(ctx context.Context, workers []string, v *jobs_
}
// 优先处理指定某ip执行
if appointIpStatus == true {
if appointIpStatus {
for wk, wv := range workers {
if gostring.Contains(wv, currentIp) == true {
c.zapLog.WithTraceId(ctx).Sugar().Info("[jobs.GetIssueAddress]优先处理指定某ip执行", traceId, workers[wk], currentIp)
if gostring.Contains(wv, currentIp) {
c.zapLog.WithTraceId(ctx).Sugar().Info("优先处理指定某ip执行", workers[wk], currentIp)
return workers[wk], nil
}
}
@ -58,7 +61,7 @@ func (c *Client) GetIssueAddress(ctx context.Context, workers []string, v *jobs_
if address == "" {
return address, errors.New("获取执行的客户端异常")
}
c.zapLog.WithTraceId(ctx).Sugar().Info("[jobs.GetIssueAddress]随机返回一个", traceId, address, currentIp)
c.zapLog.WithTraceId(ctx).Sugar().Info("随机返回一个", address, currentIp)
return address, nil
}
}
@ -66,12 +69,11 @@ func (c *Client) GetIssueAddress(ctx context.Context, workers []string, v *jobs_
// GetSubscribeClientList 获取在线的客户端
func (c *Client) GetSubscribeClientList(ctx context.Context) (client []string, err error) {
if c.config.debug == true {
c.zapLog.WithTraceId(ctx).Sugar().Info("[jobs.GetSubscribeClientList] %s\n", c.cache.cornKeyPrefix+"_*")
}
// 查询活跃的channel
client, err = c.cache.redisClient.PubSubChannels(ctx, c.cache.cornKeyPrefix+"_*").Result()
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("获取在线的客户端失败:%s%v", c.cache.cornKeyPrefix+"_*", err)
}
return client, err
}

198
run.go

@ -2,201 +2,97 @@ package gojobs
import (
"context"
"go.dtapp.net/dorm"
"go.dtapp.net/gojobs/jobs_gorm_model"
"go.dtapp.net/gojobs/jobs_mongo_model"
"go.dtapp.net/gostring"
"go.dtapp.net/gotime"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.dtapp.net/gotrace_id"
)
// Run 运行
func (c *Client) Run(ctx context.Context, info jobs_gorm_model.Task, status int, result string) {
// 任务接收记录
go func() {
if c.cache.cornKeyCustom != "" {
_, err := c.db.mongoClient.Database(c.db.mongoDatabaseName).
Collection(jobs_mongo_model.TaskReceiveRecord{}.TableName() + c.cache.cornKeyCustom).
InsertOne(&jobs_mongo_model.TaskReceiveRecord{
Id: primitive.NewObjectID(),
TaskInfo: jobs_mongo_model.TaskIssueRecordTaskInfo{
Id: info.Id,
Status: info.Status,
Params: info.Params,
ParamsType: info.ParamsType,
StatusDesc: info.StatusDesc,
Frequency: info.Frequency,
Number: info.Number,
MaxNumber: info.MaxNumber,
RunId: info.RunId,
CustomId: info.CustomId,
CustomSequence: info.CustomSequence,
Type: info.Type,
TypeName: info.TypeName,
CreatedIp: info.CreatedIp,
SpecifyIp: info.SpecifyIp,
UpdatedIp: info.UpdatedIp,
Result: info.Result,
NextRunTime: dorm.BsonTime(info.NextRunTime),
CreatedAt: dorm.BsonTime(info.CreatedAt),
UpdatedAt: dorm.BsonTime(info.UpdatedAt),
},
SystemInfo: jobs_mongo_model.TaskIssueRecordSystemInfo{
InsideIp: c.config.insideIp,
OutsideIp: c.config.outsideIp,
Os: c.config.os,
Arch: c.config.arch,
Gomaxprocs: c.config.maxProCs,
GoVersion: c.config.version,
SdkVersion: c.config.runVersion,
},
RecordTime: primitive.NewDateTimeFromTime(gotime.Current().Time),
})
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.Run.jobs_mongo_model.TaskReceiveRecord]%s", err.Error())
}
}
}()
// 请求函数记录
err := c.db.gormClient.Db.Create(&jobs_gorm_model.TaskLog{
TaskId: info.Id,
StatusCode: status,
Desc: result,
Version: c.config.runVersion,
}).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.Run.Create]%s", err.Error())
func (c *Client) Run(ctx context.Context, task jobs_gorm_model.Task, taskResultCode int, taskResultDesc string) {
runId := gotrace_id.GetTraceIdContext(ctx)
if runId == "" {
c.zapLog.WithTraceId(ctx).Sugar().Error("上下文没有跟踪编号")
return
}
// 记录
if c.db.mongoClient != nil && c.db.mongoClient.Db != nil {
go func() {
_, err = c.db.mongoClient.Database(c.db.mongoDatabaseName).
Collection(jobs_mongo_model.TaskLog{}.TableName()).
InsertOne(&jobs_mongo_model.TaskLog{
Id: primitive.NewObjectID(),
TaskId: info.Id,
StatusCode: status,
Desc: result,
Version: c.config.runVersion,
CreatedAt: primitive.NewDateTimeFromTime(gotime.Current().Time),
})
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.Run.jobs_mongo_model.TaskLog]%s", err.Error())
}
}()
c.GormTaskLogRecord(ctx, task, runId, taskResultCode, taskResultDesc)
if c.mongoConfig.stats {
c.MongoTaskLogRecord(ctx, task, runId, taskResultCode, taskResultDesc)
}
if status == 0 {
err = c.EditTask(c.db.gormClient.Db, info.Id).
switch taskResultCode {
case 0:
err := c.EditTask(c.gormClient.GetDb(), task.Id).
Select("run_id", "result", "next_run_time").
Updates(jobs_gorm_model.Task{
RunId: gostring.GetUuId(),
Result: result,
NextRunTime: gotime.Current().AfterSeconds(info.Frequency).Time,
RunId: runId,
Result: taskResultDesc,
NextRunTime: gotime.Current().AfterSeconds(task.Frequency).Time,
}).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.Run.0.EditTask]%s", err.Error())
c.zapLog.WithTraceId(ctx).Sugar().Errorf("保存失败:%s", err.Error())
}
return
}
// 任务
if status == CodeSuccess {
case CodeSuccess:
// 执行成功
err = c.EditTask(c.db.gormClient.Db, info.Id).
err := c.EditTask(c.gormClient.GetDb(), task.Id).
Select("status_desc", "number", "run_id", "updated_ip", "result", "next_run_time").
Updates(jobs_gorm_model.Task{
StatusDesc: "执行成功",
Number: info.Number + 1,
RunId: gostring.GetUuId(),
UpdatedIp: c.config.outsideIp,
Result: result,
NextRunTime: gotime.Current().AfterSeconds(info.Frequency).Time,
Number: task.Number + 1,
RunId: runId,
UpdatedIp: c.config.systemOutsideIp,
Result: taskResultDesc,
NextRunTime: gotime.Current().AfterSeconds(task.Frequency).Time,
}).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.Run.CodeSuccess.EditTask]%s", err.Error())
c.zapLog.WithTraceId(ctx).Sugar().Errorf("保存失败:%s", err.Error())
}
}
if status == CodeEnd {
case CodeEnd:
// 执行成功、提前结束
err = c.EditTask(c.db.gormClient.Db, info.Id).
err := c.EditTask(c.gormClient.GetDb(), task.Id).
Select("status", "status_desc", "number", "updated_ip", "result", "next_run_time").
Updates(jobs_gorm_model.Task{
Status: TASK_SUCCESS,
StatusDesc: "结束执行",
Number: info.Number + 1,
UpdatedIp: c.config.outsideIp,
Result: result,
Number: task.Number + 1,
UpdatedIp: c.config.systemOutsideIp,
Result: taskResultDesc,
NextRunTime: gotime.Current().Time,
}).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.Run.CodeEnd.EditTask]%s", err.Error())
c.zapLog.WithTraceId(ctx).Sugar().Errorf("保存失败:%s", err.Error())
}
}
if status == CodeError {
case CodeError:
// 执行失败
err = c.EditTask(c.db.gormClient.Db, info.Id).
err := c.EditTask(c.gormClient.GetDb(), task.Id).
Select("status_desc", "number", "run_id", "updated_ip", "result", "next_run_time").
Updates(jobs_gorm_model.Task{
StatusDesc: "执行失败",
Number: info.Number + 1,
RunId: gostring.GetUuId(),
UpdatedIp: c.config.outsideIp,
Result: result,
NextRunTime: gotime.Current().AfterSeconds(info.Frequency).Time,
Number: task.Number + 1,
RunId: runId,
UpdatedIp: c.config.systemOutsideIp,
Result: taskResultDesc,
NextRunTime: gotime.Current().AfterSeconds(task.Frequency).Time,
}).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.Run.CodeError.EditTask]%s", err.Error())
c.zapLog.WithTraceId(ctx).Sugar().Errorf("保存失败%s", err.Error())
}
}
if info.MaxNumber != 0 {
if info.Number+1 >= info.MaxNumber {
if task.MaxNumber != 0 {
if task.Number+1 >= task.MaxNumber {
// 关闭执行
err = c.EditTask(c.db.gormClient.Db, info.Id).
err := c.EditTask(c.gormClient.GetDb(), task.Id).
Select("status").
Updates(jobs_gorm_model.Task{
Status: TASK_TIMEOUT,
}).Error
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.Run.TASK_TIMEOUT.EditTask]%s", err.Error())
c.zapLog.WithTraceId(ctx).Sugar().Errorf("保存失败%s", err.Error())
}
}
}
}
// RunAddLog 任务执行日志
func (c *Client) RunAddLog(ctx context.Context, id uint, runId string) error {
if c.db.mongoClient != nil && c.db.mongoClient.Db != nil {
go func() {
_, err := c.db.mongoClient.Database(c.db.mongoDatabaseName).
Collection(jobs_mongo_model.TaskLogRun{}.TableName()).
InsertOne(&jobs_mongo_model.TaskLogRun{
Id: primitive.NewObjectID(),
TaskId: id,
RunId: runId,
InsideIp: c.config.insideIp,
OutsideIp: c.config.outsideIp,
Os: c.config.os,
Arch: c.config.arch,
Gomaxprocs: c.config.maxProCs,
GoVersion: c.config.version,
SdkVersion: c.config.runVersion,
MacAddrs: c.config.macAddrS,
CreatedAt: primitive.NewDateTimeFromTime(gotime.Current().Time),
})
if err != nil {
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.RunAddLog.jobs_mongo_model.TaskLogRun]%s", err.Error())
}
}()
}
return c.db.gormClient.Db.Create(&jobs_gorm_model.TaskLogRun{
TaskId: id,
RunId: runId,
InsideIp: c.config.insideIp,
OutsideIp: c.config.outsideIp,
Os: c.config.os,
Arch: c.config.arch,
Gomaxprocs: c.config.maxProCs,
GoVersion: c.config.version,
SdkVersion: c.config.runVersion,
MacAddrs: c.config.macAddrS,
}).Error
return
}

@ -0,0 +1,73 @@
package gojobs
import (
"context"
"errors"
"go.dtapp.net/gojobs/jobs_gorm_model"
)
type TaskLockOperation struct {
client *Client // 实例
task jobs_gorm_model.Task // 任务
}
func (c *Client) NewLock(task jobs_gorm_model.Task) (*TaskLockOperation, error) {
if task.Id == 0 {
return nil, errors.New("任务数据不正常")
}
return &TaskLockOperation{
client: c,
task: task,
}, nil
}
// Lock 上锁
func (tlo *TaskLockOperation) Lock(ctx context.Context, id any) error {
_, err := tlo.client.Lock(ctx, tlo.task, id)
return err
}
// Unlock 解锁
func (tlo *TaskLockOperation) Unlock(ctx context.Context, id any) error {
return tlo.client.Unlock(ctx, tlo.task, id)
}
// LockForever 永远上锁
func (tlo *TaskLockOperation) LockForever(ctx context.Context, id any) error {
_, err := tlo.client.LockForever(ctx, tlo.task, id)
return err
}
// LockId 上锁
func (tlo *TaskLockOperation) LockId(ctx context.Context) error {
_, err := tlo.client.LockId(ctx, tlo.task)
return err
}
// UnlockId 解锁
func (tlo *TaskLockOperation) UnlockId(ctx context.Context) error {
return tlo.client.UnlockId(ctx, tlo.task)
}
// LockForeverId 永远上锁
func (tlo *TaskLockOperation) LockForeverId(ctx context.Context) error {
_, err := tlo.client.LockForeverId(ctx, tlo.task)
return err
}
// LockCustomId 上锁
func (tlo *TaskLockOperation) LockCustomId(ctx context.Context) error {
_, err := tlo.client.LockCustomId(ctx, tlo.task)
return err
}
// UnlockCustomId 解锁
func (tlo *TaskLockOperation) UnlockCustomId(ctx context.Context) error {
return tlo.client.UnlockCustomId(ctx, tlo.task)
}
// LockForeverCustomId 永远上锁
func (tlo *TaskLockOperation) LockForeverCustomId(ctx context.Context) error {
_, err := tlo.client.LockForeverCustomId(ctx, tlo.task)
return err
}
Loading…
Cancel
Save