Documentation ¶
Index ¶
- Constants
- Variables
- func GetTypeApiPaySubmit(Type string) string
- func GetTypeCustomerAuto(Type string) string
- func GetTypeGoldenBeansIssue(Type string) string
- func GetTypeGoldenBeansRefunds(Type string) string
- func GetTypeWechatRefundsQuery(Type string) string
- func GetTypeWechatRefundsSubmit(Type string) string
- type App
- func (app *App) Add(tx *gorm.DB, Type string, params interface{}, frequency int64) *gorm.DB
- func (app *App) AddCustomId(tx *gorm.DB, Type string, params interface{}, frequency int64, customId string) *gorm.DB
- func (app *App) AddCustomIdMaxNumber(tx *gorm.DB, Type string, params interface{}, frequency int64, customId string, ...) *gorm.DB
- func (app *App) AddIn(tx *gorm.DB, param TaskParams, params interface{}) *gorm.DB
- func (app *App) AddInMerchantGoldenBean(tx *gorm.DB, Type string, params interface{}, frequency int64) *gorm.DB
- func (app *App) AddInNewService(tx *gorm.DB, Type string, params interface{}, frequency int64) *gorm.DB
- func (app *App) AddInOrder(tx *gorm.DB, Type string, params interface{}, frequency int64) *gorm.DB
- func (app *App) AddInOrderCustomId(tx *gorm.DB, Type string, params interface{}, frequency int64, customId string) *gorm.DB
- func (app *App) AddInOrderCustomIdObservation(tx *gorm.DB, Type string, customId string) *gorm.DB
- func (app *App) AddInOrderCustomIdObservationClone(tx *gorm.DB, Type string, customId string) *gorm.DB
- func (app *App) AddInOrderCustomIdSpecifyIp(tx *gorm.DB, Type string, params interface{}, frequency int64, ...) *gorm.DB
- func (app *App) AddInTeamInv(tx *gorm.DB, Type string, params interface{}, frequency int64) *gorm.DB
- func (app *App) AddInUserShareInvitation(tx *gorm.DB, Type string, params interface{}, frequency int64) *gorm.DB
- func (app *App) AddWait(tx *gorm.DB, param TaskParams, params interface{}) *gorm.DB
- func (app *App) AddWaitNewServiceNext(tx *gorm.DB, param TaskParams, params interface{}) *gorm.DB
- func (app *App) Check(tx *gorm.DB, vs []Task)
- func (app *App) Edit(tx *gorm.DB, id uint) *gorm.DB
- func (app *App) Lock(info Task, id any) string
- func (app *App) LockForever(info Task, id any) string
- func (app *App) RefreshIp(tx *gorm.DB)
- func (app *App) Run(tx *gorm.DB, info Task, status int, desc string)
- func (app *App) RunAddLog(tx *gorm.DB, id uint, runId string) *gorm.DB
- func (app *App) Start(tx *gorm.DB, customId string, customSequence int64) *gorm.DB
- func (app *App) TaskCustomIdTake(tx *gorm.DB, Type, customId string) (result Task)
- func (app *App) TaskCustomIdTakeStatus(tx *gorm.DB, Type, customId, status string) (result Task)
- func (app *App) TaskFind(tx *gorm.DB, frequency int64) (results []Task)
- func (app *App) TaskFindAll(tx *gorm.DB, frequency int64) (results []Task)
- func (app *App) TaskIpInit(tx *gorm.DB, ips map[string]string) bool
- func (app *App) TaskIpUpdate(tx *gorm.DB, taskType, ips string) *gorm.DB
- func (app *App) TaskLogRunTake(tx *gorm.DB, taskId uint, runId string) (result TaskLogRun)
- func (app *App) TaskTake(tx *gorm.DB, customId string) (result Task)
- func (app *App) Unlock(info Task, id any)
- func (app *App) UpdateFrequency(tx *gorm.DB, id uint, frequency int64) *gorm.DB
- type ParamsOrderId
- type ParamsTaskId
- type ParamsTaskIdNext
- type Task
- type TaskIp
- type TaskLog
- type TaskLogRun
- type TaskParams
Constants ¶
const ( CodeAbnormal = 0 // 异常 CodeError = http.StatusInternalServerError // 失败 CodeSuccess = http.StatusOK // 成功 CodeEnd = http.StatusCreated // 结束 )
const ( TASK_IN = "IN" // 任务运行 TASK_SUCCESS = "SUCCESS" // 任务完成 TASK_ERROR = "ERROR" // 任务异常 TASK_TIMEOUT = "TIMEOUT" // 任务超时 TASK_WAIT = "WAIT" // 任务等待 )
const Version = "1.0.16"
Variables ¶
var GetFrequencyHour = func(n int64) int64 {
if n < 0 && n > 23 {
return -1
}
return n * 60 * 60
}
GetFrequencyHour 每天n点执行一次
var GetFrequencyMinutes = func(n int64) int64 {
if n < 0 && n > 59 {
return -1
}
return n * 60
}
GetFrequencyMinutes 每隔n分钟执行一次
var GetFrequencySeconds = func(n int64) int64 {
if n < 0 && n > 59 {
return -1
}
return n
}
GetFrequencySeconds 每隔n秒执行一次
var GetSpecHour = func(n int64) string { if n < 0 && n > 23 { return "" } return fmt.Sprintf(specHour, n) }
GetSpecHour 每天n点执行一次
var GetSpecMinutes = func(n int64) string { if n < 0 && n > 59 { return "" } return fmt.Sprintf(specMinutes, n) }
GetSpecMinutes 每隔n分钟执行一次
var GetSpecSeconds = func(n int64) string { if n < 0 && n > 59 { return "" } return fmt.Sprintf(specSeconds, n) }
GetSpecSeconds 每隔n秒执行一次
var ParamsMerchantGoldenBeanType = "merchant.golden_bean"
var ParamsNewServiceNextType = "new_service.next"
var ParamsNewServiceType = "new_service"
var ParamsOrderType = "order"
var ParamsTeamInvType = "team.inv"
Functions ¶
func GetTypeApiPaySubmit ¶
func GetTypeCustomerAuto ¶
func GetTypeGoldenBeansIssue ¶
Types ¶
type App ¶
type App struct { RunVersion int `json:"run_version"` // 运行版本 Os string `json:"os"` // 系统类型 Arch string `json:"arch"` // 系统架构 MaxProCs int `json:"max_pro_cs"` // CPU核数 Version string `json:"version"` // GO版本 MacAddrS string `json:"mac_addr_s"` // Mac地址 InsideIp string `json:"inside_ip"` // 内网ip OutsideIp string `json:"outside_ip"` // 外网ip MainService int `json:"main_service"` // 主要服务 Db *gorm.DB // 数据库 Redis *dorm.RedisClient // 缓存数据库服务 }
func (*App) AddCustomId ¶
func (app *App) AddCustomId(tx *gorm.DB, Type string, params interface{}, frequency int64, customId string) *gorm.DB
AddCustomId 添加任务
func (*App) AddCustomIdMaxNumber ¶
func (app *App) AddCustomIdMaxNumber(tx *gorm.DB, Type string, params interface{}, frequency int64, customId string, maxNumber int64) *gorm.DB
AddCustomIdMaxNumber 添加任务并设置最大数量
func (*App) AddIn ¶
AddIn 添加可执行任务 params.Type 任务类型 params.Frequency 任务频率 params.CustomId 自定义编号 params 任务参数
func (*App) AddInMerchantGoldenBean ¶
func (app *App) AddInMerchantGoldenBean(tx *gorm.DB, Type string, params interface{}, frequency int64) *gorm.DB
AddInMerchantGoldenBean 添加商家金豆可执行任务
func (*App) AddInNewService ¶
func (app *App) AddInNewService(tx *gorm.DB, Type string, params interface{}, frequency int64) *gorm.DB
AddInNewService 添加企业自定义可执行任务
func (*App) AddInOrder ¶
AddInOrder 添加订单可执行任务
func (*App) AddInOrderCustomId ¶
func (app *App) AddInOrderCustomId(tx *gorm.DB, Type string, params interface{}, frequency int64, customId string) *gorm.DB
AddInOrderCustomId 添加订单可执行任务
func (*App) AddInOrderCustomIdObservation ¶
AddInOrderCustomIdObservation 添加观察接口任务
func (*App) AddInOrderCustomIdObservationClone ¶
func (app *App) AddInOrderCustomIdObservationClone(tx *gorm.DB, Type string, customId string) *gorm.DB
AddInOrderCustomIdObservationClone 观察接口关闭
func (*App) AddInOrderCustomIdSpecifyIp ¶
func (app *App) AddInOrderCustomIdSpecifyIp(tx *gorm.DB, Type string, params interface{}, frequency int64, customId, specifyIp string) *gorm.DB
AddInOrderCustomIdSpecifyIp 添加订单可执行任务
func (*App) AddInTeamInv ¶
func (app *App) AddInTeamInv(tx *gorm.DB, Type string, params interface{}, frequency int64) *gorm.DB
AddInTeamInv 添加团队邀请可执行任务
func (*App) AddInUserShareInvitation ¶
func (app *App) AddInUserShareInvitation(tx *gorm.DB, Type string, params interface{}, frequency int64) *gorm.DB
AddInUserShareInvitation 邀请好友
func (*App) AddWait ¶
AddWait 添加等待执行任务 params.Type 任务类型 params.Frequency 任务频率 params.CustomId 自定义编号 params.CustomSequence 自定义顺序 params 任务参数
func (*App) AddWaitNewServiceNext ¶
AddWaitNewServiceNext 添加企业自定义下一步等待执行任务
func (*App) TaskCustomIdTake ¶
TaskCustomIdTake 查询任务
func (*App) TaskCustomIdTakeStatus ¶
TaskCustomIdTakeStatus 查询任务
func (*App) TaskFindAll ¶
TaskFindAll 查询任务
func (*App) TaskIpInit ¶
TaskIpInit 实例任务ip
func (*App) TaskLogRunTake ¶
TaskLogRunTake 查询任务执行日志
type ParamsOrderId ¶
type ParamsOrderId struct {
OrderId string `json:"order_id,omitempty"`
}
ParamsOrderId 订单任务
type ParamsTaskId ¶
type ParamsTaskId struct {
TaskId int64 `json:"task_id,omitempty"`
}
ParamsTaskId 企业自定义任务
type ParamsTaskIdNext ¶
type ParamsTaskIdNext struct { TaskId int64 `json:"task_id,omitempty"` MerchantUserId int64 `json:"merchant_user_id,omitempty"` CurrentNumber int `json:"current_number,omitempty"` MaxNumber int `json:"max_number,omitempty"` }
ParamsTaskIdNext 企业自定义下一步任务
type Task ¶
type Task struct { Id uint `gorm:"primaryKey" 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"` // 结果 CreatedAt string `gorm:"type:text" json:"created_at"` // 创建时间 UpdatedAt string `gorm:"type:text" json:"updated_at"` // 更新时间 }
Task 任务
type TaskIp ¶
type TaskIp struct { Id int64 TaskType string `json:"task_type"` // 任务编号 Ips string `json:"ips"` // 任务IP }
TaskIp 任务Ip
type TaskLog ¶
type TaskLog struct { Id uint `gorm:"primaryKey" json:"id"` // 记录编号 TaskId uint `json:"task_id"` // 任务编号 StatusCode int `json:"status_code"` // 状态码 Desc string `json:"desc"` // 结果 Version int `json:"version"` // 版本 CreatedAt string `gorm:"type:text" json:"created_at"` // 创建时间 }
TaskLog 任务日志
type TaskLogRun ¶
type TaskLogRun struct { Id uint `gorm:"primaryKey" 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版本 MacAddrs string `json:"mac_addrs"` // Mac地址 CreatedAt string `gorm:"type:text" json:"created_at"` // 创建时间 }
TaskLogRun 任务执行日志
func (*TaskLogRun) TableName ¶
func (m *TaskLogRun) TableName() string
type TaskParams ¶
type TaskParams = Task