|
|
|
@ -4,12 +4,8 @@ import (
|
|
|
|
|
"context"
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"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"
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -48,62 +44,6 @@ func (c *Client) CreateInCustomId(ctx context.Context, config *ConfigCreateInCus
|
|
|
|
|
if err != nil {
|
|
|
|
|
return errors.New(fmt.Sprintf("创建[%s@%s]任务失败:%s", config.CustomId, config.Type, err.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.Task{}.TableName()).
|
|
|
|
|
InsertOne(ctx, &jobs_mongo_model.Task{
|
|
|
|
|
Id: primitive.NewObjectID(),
|
|
|
|
|
Status: TASK_IN,
|
|
|
|
|
Params: config.Params,
|
|
|
|
|
StatusDesc: "首次添加任务",
|
|
|
|
|
Frequency: config.Frequency,
|
|
|
|
|
RunId: gostring.GetUuId(),
|
|
|
|
|
CustomId: config.CustomId,
|
|
|
|
|
CustomSequence: config.CustomSequence,
|
|
|
|
|
Type: config.Type,
|
|
|
|
|
TypeName: config.TypeName,
|
|
|
|
|
SpecifyIp: config.SpecifyIp,
|
|
|
|
|
CreateRunInfo: jobs_mongo_model.TaskRunInfo{
|
|
|
|
|
SystemHostName: c.config.systemHostName,
|
|
|
|
|
SystemInsideIp: c.config.systemInsideIp,
|
|
|
|
|
SystemOs: c.config.systemOs,
|
|
|
|
|
SystemArch: c.config.systemArch,
|
|
|
|
|
SystemCpuQuantity: c.config.systemCpuQuantity,
|
|
|
|
|
GoVersion: c.config.goVersion,
|
|
|
|
|
SdkVersion: c.config.sdkVersion,
|
|
|
|
|
RunTime: dorm.NewBsonTimeCurrent(),
|
|
|
|
|
RunIp: config.CurrentIp,
|
|
|
|
|
},
|
|
|
|
|
CurrentRunInfo: jobs_mongo_model.TaskRunInfo{
|
|
|
|
|
SystemHostName: c.config.systemHostName,
|
|
|
|
|
SystemInsideIp: c.config.systemInsideIp,
|
|
|
|
|
SystemOs: c.config.systemOs,
|
|
|
|
|
SystemArch: c.config.systemArch,
|
|
|
|
|
SystemCpuQuantity: c.config.systemCpuQuantity,
|
|
|
|
|
GoVersion: c.config.goVersion,
|
|
|
|
|
SdkVersion: c.config.sdkVersion,
|
|
|
|
|
RunTime: dorm.NewBsonTimeCurrent(),
|
|
|
|
|
RunIp: config.CurrentIp,
|
|
|
|
|
},
|
|
|
|
|
NextRunInfo: jobs_mongo_model.TaskRunInfo{
|
|
|
|
|
SystemHostName: c.config.systemHostName,
|
|
|
|
|
SystemInsideIp: c.config.systemInsideIp,
|
|
|
|
|
SystemOs: c.config.systemOs,
|
|
|
|
|
SystemArch: c.config.systemArch,
|
|
|
|
|
SystemCpuQuantity: c.config.systemCpuQuantity,
|
|
|
|
|
GoVersion: c.config.goVersion,
|
|
|
|
|
SdkVersion: c.config.sdkVersion,
|
|
|
|
|
RunTime: dorm.NewBsonTimeFromTime(gotime.Current().AfterSeconds(config.Frequency).Time),
|
|
|
|
|
RunIp: config.CurrentIp,
|
|
|
|
|
},
|
|
|
|
|
CreateTime: primitive.NewDateTimeFromTime(gotime.Current().Time),
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.CreateInCustomId]:%s", err.Error())
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -146,62 +86,6 @@ func (c *Client) CreateInCustomIdOnly(ctx context.Context, config *ConfigCreateI
|
|
|
|
|
if err != nil {
|
|
|
|
|
return errors.New(fmt.Sprintf("创建[%s@%s]任务失败:%s", config.CustomId, config.Type, err.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.Task{}.TableName()).
|
|
|
|
|
InsertOne(ctx, &jobs_mongo_model.Task{
|
|
|
|
|
Id: primitive.NewObjectID(),
|
|
|
|
|
Status: TASK_IN,
|
|
|
|
|
Params: config.Params,
|
|
|
|
|
StatusDesc: "首次添加任务",
|
|
|
|
|
Frequency: config.Frequency,
|
|
|
|
|
RunId: gostring.GetUuId(),
|
|
|
|
|
CustomId: config.CustomId,
|
|
|
|
|
CustomSequence: config.CustomSequence,
|
|
|
|
|
Type: config.Type,
|
|
|
|
|
TypeName: config.TypeName,
|
|
|
|
|
SpecifyIp: config.SpecifyIp,
|
|
|
|
|
CreateRunInfo: jobs_mongo_model.TaskRunInfo{
|
|
|
|
|
SystemHostName: c.config.systemHostName,
|
|
|
|
|
SystemInsideIp: c.config.systemInsideIp,
|
|
|
|
|
SystemOs: c.config.systemOs,
|
|
|
|
|
SystemArch: c.config.systemArch,
|
|
|
|
|
SystemCpuQuantity: c.config.systemCpuQuantity,
|
|
|
|
|
GoVersion: c.config.goVersion,
|
|
|
|
|
SdkVersion: c.config.sdkVersion,
|
|
|
|
|
RunTime: dorm.NewBsonTimeCurrent(),
|
|
|
|
|
RunIp: config.CurrentIp,
|
|
|
|
|
},
|
|
|
|
|
CurrentRunInfo: jobs_mongo_model.TaskRunInfo{
|
|
|
|
|
SystemHostName: c.config.systemHostName,
|
|
|
|
|
SystemInsideIp: c.config.systemInsideIp,
|
|
|
|
|
SystemOs: c.config.systemOs,
|
|
|
|
|
SystemArch: c.config.systemArch,
|
|
|
|
|
SystemCpuQuantity: c.config.systemCpuQuantity,
|
|
|
|
|
GoVersion: c.config.goVersion,
|
|
|
|
|
SdkVersion: c.config.sdkVersion,
|
|
|
|
|
RunTime: dorm.NewBsonTimeCurrent(),
|
|
|
|
|
RunIp: config.CurrentIp,
|
|
|
|
|
},
|
|
|
|
|
NextRunInfo: jobs_mongo_model.TaskRunInfo{
|
|
|
|
|
SystemHostName: c.config.systemHostName,
|
|
|
|
|
SystemInsideIp: c.config.systemInsideIp,
|
|
|
|
|
SystemOs: c.config.systemOs,
|
|
|
|
|
SystemArch: c.config.systemArch,
|
|
|
|
|
SystemCpuQuantity: c.config.systemCpuQuantity,
|
|
|
|
|
GoVersion: c.config.goVersion,
|
|
|
|
|
SdkVersion: c.config.sdkVersion,
|
|
|
|
|
RunTime: dorm.NewBsonTimeFromTime(gotime.Current().AfterSeconds(config.Frequency).Time),
|
|
|
|
|
RunIp: config.CurrentIp,
|
|
|
|
|
},
|
|
|
|
|
CreateTime: primitive.NewDateTimeFromTime(gotime.Current().Time),
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.CreateInCustomIdOnly]:%s", err.Error())
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -242,63 +126,6 @@ func (c *Client) CreateInCustomIdMaxNumber(ctx context.Context, config *ConfigCr
|
|
|
|
|
if err != nil {
|
|
|
|
|
return errors.New(fmt.Sprintf("创建[%s@%s]任务失败:%s", config.CustomId, config.Type, err.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.Task{}.TableName()).
|
|
|
|
|
InsertOne(ctx, &jobs_mongo_model.Task{
|
|
|
|
|
Id: primitive.NewObjectID(),
|
|
|
|
|
Status: TASK_IN,
|
|
|
|
|
Params: config.Params,
|
|
|
|
|
StatusDesc: "首次添加任务",
|
|
|
|
|
Frequency: config.Frequency,
|
|
|
|
|
MaxNumber: config.MaxNumber,
|
|
|
|
|
RunId: gostring.GetUuId(),
|
|
|
|
|
CustomId: config.CustomId,
|
|
|
|
|
CustomSequence: config.CustomSequence,
|
|
|
|
|
Type: config.Type,
|
|
|
|
|
TypeName: config.TypeName,
|
|
|
|
|
SpecifyIp: config.SpecifyIp,
|
|
|
|
|
CreateRunInfo: jobs_mongo_model.TaskRunInfo{
|
|
|
|
|
SystemHostName: c.config.systemHostName,
|
|
|
|
|
SystemInsideIp: c.config.systemInsideIp,
|
|
|
|
|
SystemOs: c.config.systemOs,
|
|
|
|
|
SystemArch: c.config.systemArch,
|
|
|
|
|
SystemCpuQuantity: c.config.systemCpuQuantity,
|
|
|
|
|
GoVersion: c.config.goVersion,
|
|
|
|
|
SdkVersion: c.config.sdkVersion,
|
|
|
|
|
RunTime: dorm.NewBsonTimeCurrent(),
|
|
|
|
|
RunIp: config.CurrentIp,
|
|
|
|
|
},
|
|
|
|
|
CurrentRunInfo: jobs_mongo_model.TaskRunInfo{
|
|
|
|
|
SystemHostName: c.config.systemHostName,
|
|
|
|
|
SystemInsideIp: c.config.systemInsideIp,
|
|
|
|
|
SystemOs: c.config.systemOs,
|
|
|
|
|
SystemArch: c.config.systemArch,
|
|
|
|
|
SystemCpuQuantity: c.config.systemCpuQuantity,
|
|
|
|
|
GoVersion: c.config.goVersion,
|
|
|
|
|
SdkVersion: c.config.sdkVersion,
|
|
|
|
|
RunTime: dorm.NewBsonTimeCurrent(),
|
|
|
|
|
RunIp: config.CurrentIp,
|
|
|
|
|
},
|
|
|
|
|
NextRunInfo: jobs_mongo_model.TaskRunInfo{
|
|
|
|
|
SystemHostName: c.config.systemHostName,
|
|
|
|
|
SystemInsideIp: c.config.systemInsideIp,
|
|
|
|
|
SystemOs: c.config.systemOs,
|
|
|
|
|
SystemArch: c.config.systemArch,
|
|
|
|
|
SystemCpuQuantity: c.config.systemCpuQuantity,
|
|
|
|
|
GoVersion: c.config.goVersion,
|
|
|
|
|
SdkVersion: c.config.sdkVersion,
|
|
|
|
|
RunTime: dorm.NewBsonTimeFromTime(gotime.Current().AfterSeconds(config.Frequency).Time),
|
|
|
|
|
RunIp: config.CurrentIp,
|
|
|
|
|
},
|
|
|
|
|
CreateTime: primitive.NewDateTimeFromTime(gotime.Current().Time),
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.CreateInCustomIdMaxNumber]:%s", err.Error())
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -343,62 +170,5 @@ func (c *Client) CreateInCustomIdMaxNumberOnly(ctx context.Context, config *Conf
|
|
|
|
|
if err != nil {
|
|
|
|
|
return errors.New(fmt.Sprintf("创建[%s@%s]任务失败:%s", config.CustomId, config.Type, err.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.Task{}.TableName()).
|
|
|
|
|
InsertOne(ctx, &jobs_mongo_model.Task{
|
|
|
|
|
Id: primitive.NewObjectID(),
|
|
|
|
|
Status: TASK_IN,
|
|
|
|
|
Params: config.Params,
|
|
|
|
|
StatusDesc: "首次添加任务",
|
|
|
|
|
Frequency: config.Frequency,
|
|
|
|
|
MaxNumber: config.MaxNumber,
|
|
|
|
|
RunId: gostring.GetUuId(),
|
|
|
|
|
CustomId: config.CustomId,
|
|
|
|
|
CustomSequence: config.CustomSequence,
|
|
|
|
|
Type: config.Type,
|
|
|
|
|
TypeName: config.TypeName,
|
|
|
|
|
SpecifyIp: config.SpecifyIp,
|
|
|
|
|
CreateRunInfo: jobs_mongo_model.TaskRunInfo{
|
|
|
|
|
SystemHostName: c.config.systemHostName,
|
|
|
|
|
SystemInsideIp: c.config.systemInsideIp,
|
|
|
|
|
SystemOs: c.config.systemOs,
|
|
|
|
|
SystemArch: c.config.systemArch,
|
|
|
|
|
SystemCpuQuantity: c.config.systemCpuQuantity,
|
|
|
|
|
GoVersion: c.config.goVersion,
|
|
|
|
|
SdkVersion: c.config.sdkVersion,
|
|
|
|
|
RunTime: dorm.NewBsonTimeCurrent(),
|
|
|
|
|
RunIp: config.CurrentIp,
|
|
|
|
|
},
|
|
|
|
|
CurrentRunInfo: jobs_mongo_model.TaskRunInfo{
|
|
|
|
|
SystemHostName: c.config.systemHostName,
|
|
|
|
|
SystemInsideIp: c.config.systemInsideIp,
|
|
|
|
|
SystemOs: c.config.systemOs,
|
|
|
|
|
SystemArch: c.config.systemArch,
|
|
|
|
|
SystemCpuQuantity: c.config.systemCpuQuantity,
|
|
|
|
|
GoVersion: c.config.goVersion,
|
|
|
|
|
SdkVersion: c.config.sdkVersion,
|
|
|
|
|
RunTime: dorm.NewBsonTimeCurrent(),
|
|
|
|
|
RunIp: config.CurrentIp,
|
|
|
|
|
},
|
|
|
|
|
NextRunInfo: jobs_mongo_model.TaskRunInfo{
|
|
|
|
|
SystemHostName: c.config.systemHostName,
|
|
|
|
|
SystemInsideIp: c.config.systemInsideIp,
|
|
|
|
|
SystemOs: c.config.systemOs,
|
|
|
|
|
SystemArch: c.config.systemArch,
|
|
|
|
|
SystemCpuQuantity: c.config.systemCpuQuantity,
|
|
|
|
|
GoVersion: c.config.goVersion,
|
|
|
|
|
SdkVersion: c.config.sdkVersion,
|
|
|
|
|
RunTime: dorm.NewBsonTimeFromTime(gotime.Current().AfterSeconds(config.Frequency).Time),
|
|
|
|
|
RunIp: config.CurrentIp,
|
|
|
|
|
},
|
|
|
|
|
CreateTime: primitive.NewDateTimeFromTime(gotime.Current().Time),
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.zapLog.WithTraceId(ctx).Sugar().Errorf("[gojobs.CreateInCustomIdMaxNumberOnly]:%s", err.Error())
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|