Documentation ¶
Index ¶
- Constants
- func EntTaskAnnotations() []schema.Annotation
- func EntTaskFields() []ent.Field
- func EntTaskIndexes() []ent.Index
- func EntTaskLogAnnotations() []schema.Annotation
- func EntTaskLogFields() []ent.Field
- func EntTaskLogIndexes() []ent.Index
- func GetRedisKeyName(taskType string) string
- func NewTraceStartSpan(ctx context.Context, spanName string) (context.Context, trace.Span)
- func SetRedisKeyValue(ctx context.Context, taskType string) (context.Context, string, any, time.Duration)
- func SetRedisKeyValueExpiration(ctx context.Context, taskType string, expiration int64) (context.Context, string, any, time.Duration)
- func TraceEndSpan(span trace.Span)
- func TraceGetSpanID(ctx context.Context) (spanID string)
- func TraceGetTraceID(ctx context.Context) (traceID string)
- func TraceRecordError(ctx context.Context, err error, options ...trace.EventOption)
- func TraceSetAttributes(ctx context.Context, kv ...attribute.KeyValue)
- func TraceSetStatus(ctx context.Context, code codes.Code, description string)
- func TraceStartSpan(ctx context.Context, spanName string) (context.Context, trace.Span)
- type Client
- func (c *Client) ConfigGormClientFun(ctx context.Context, client *gorm.DB, taskTableName string, taskLogStatus bool, ...) error
- func (c *Client) ConfigRedisClientFun(ctx context.Context, client *redis.Client, lockKeyPrefix string, ...) error
- func (c *Client) CreateInCustomId(ctx context.Context, config *ConfigCreateInCustomId) error
- func (c *Client) CreateInCustomIdMaxNumber(ctx context.Context, config *ConfigCreateInCustomIdMaxNumber) error
- func (c *Client) CreateInCustomIdMaxNumberOnly(ctx context.Context, config *ConfigCreateInCustomIdMaxNumberOnly) error
- func (c *Client) CreateInCustomIdOnly(ctx context.Context, config *ConfigCreateInCustomIdOnly) error
- func (c *Client) CreateWaitCustomId(ctx context.Context, config *ConfigCreateWaitCustomId) error
- func (c *Client) EditTask(ctx context.Context, tx *gorm.DB, id uint) *gorm.DB
- func (c *Client) EndHandle(ctx context.Context, key any)
- func (c *Client) Filter(ctx context.Context, isMandatoryIp bool, specifyIp string, ...) (newTasks []GormModelTask)
- func (c *Client) GetCurrentIp() string
- func (c *Client) GetDb() *gorm.DB
- func (c *Client) GetGormDb() *gorm.DB
- func (c *Client) GetIssueAddress(ctx context.Context, workers []string, v *GormModelTask) (string, error)
- func (c *Client) GetRedisDb() *redis.Client
- func (c *Client) GetSubscribeAddress() string
- func (c *Client) GetSubscribeClientList(ctx context.Context) (client []string, err error)
- func (c *Client) GormTaskLogDelete(ctx context.Context, hour int64) error
- func (c *Client) GormTaskLogErrorDelete(ctx context.Context, hour int64) error
- func (c *Client) GormTaskLogInDelete(ctx context.Context, hour int64) error
- func (c *Client) GormTaskLogRecord(ctx context.Context, task GormModelTask, runId string, taskResultCode int, ...)
- func (c *Client) GormTaskLogSuccessDelete(ctx context.Context, hour int64) error
- func (c *Client) GormTaskLogTimeoutDelete(ctx context.Context, hour int64) error
- func (c *Client) GormTaskLogWaitDelete(ctx context.Context, hour int64) error
- func (c *Client) Lock(ctx context.Context, info *GormModelTask, id any) (string, error)
- func (c *Client) LockCustomId(ctx context.Context, info *GormModelTask) (string, error)
- func (c *Client) LockForever(ctx context.Context, info *GormModelTask, id any) (string, error)
- func (c *Client) LockForeverCustomId(ctx context.Context, info *GormModelTask) (string, error)
- func (c *Client) LockForeverId(ctx context.Context, info *GormModelTask) (string, error)
- func (c *Client) LockId(ctx context.Context, info *GormModelTask) (string, error)
- func (c *Client) NewLock(task *GormModelTask) (*TaskLockOperation, error)
- func (c *Client) PSubscribe(ctx context.Context) SubscribeResult
- func (c *Client) Publish(ctx context.Context, channel string, message interface{}) error
- func (c *Client) Run(ctx context.Context, task GormModelTask, taskResultCode int, ...)
- func (c *Client) StartCronClean(ctx context.Context, cr *cron.Cron, cp string, hour int64) (cron.EntryID, error)
- func (c *Client) StartHandle(ctx context.Context, key any, overdue int64) error
- func (c *Client) StartTask(ctx context.Context, tx *gorm.DB, id uint) error
- func (c *Client) StartTaskCustom(ctx context.Context, tx *gorm.DB, customId string, customSequence int64) error
- func (c *Client) Subscribe(ctx context.Context) SubscribeResult
- func (c *Client) TaskFindAll(ctx context.Context, tx *gorm.DB, frequency int64) (results []GormModelTask)
- func (c *Client) TaskFindAllError(ctx context.Context, tx *gorm.DB, frequency int64) []GormModelTask
- func (c *Client) TaskFindAllErrorType(ctx context.Context, tx *gorm.DB, Type string) []GormModelTask
- func (c *Client) TaskFindAllIn(ctx context.Context, tx *gorm.DB, frequency int64) []GormModelTask
- func (c *Client) TaskFindAllInType(ctx context.Context, tx *gorm.DB, Type string) []GormModelTask
- func (c *Client) TaskFindAllSuccess(ctx context.Context, tx *gorm.DB, frequency int64) []GormModelTask
- func (c *Client) TaskFindAllSuccessType(ctx context.Context, tx *gorm.DB, Type string) []GormModelTask
- func (c *Client) TaskFindAllTimeout(ctx context.Context, tx *gorm.DB, frequency int64) []GormModelTask
- func (c *Client) TaskFindAllTimeoutType(ctx context.Context, tx *gorm.DB, Type string) []GormModelTask
- func (c *Client) TaskFindAllType(ctx context.Context, tx *gorm.DB, Type string, frequency int64) (results []GormModelTask)
- func (c *Client) TaskFindAllWait(ctx context.Context, tx *gorm.DB, frequency int64) []GormModelTask
- func (c *Client) TaskFindAllWaitType(ctx context.Context, tx *gorm.DB, Type string) []GormModelTask
- func (c *Client) TaskTake(ctx context.Context, tx *gorm.DB, customId string) (result GormModelTask)
- func (c *Client) TaskTakeError(ctx context.Context, tx *gorm.DB, customId string) GormModelTask
- func (c *Client) TaskTakeId(ctx context.Context, tx *gorm.DB, id uint) (result GormModelTask)
- func (c *Client) TaskTakeIn(ctx context.Context, tx *gorm.DB, customId string) GormModelTask
- func (c *Client) TaskTakeSuccess(ctx context.Context, tx *gorm.DB, customId string) GormModelTask
- func (c *Client) TaskTakeTimeout(ctx context.Context, tx *gorm.DB, customId string) GormModelTask
- func (c *Client) TaskTakeWait(ctx context.Context, tx *gorm.DB, customId string) GormModelTask
- func (c *Client) TaskTypeTake(ctx context.Context, tx *gorm.DB, customId, Type string) (result GormModelTask)
- func (c *Client) TaskTypeTakeError(ctx context.Context, tx *gorm.DB, customId, Type string) GormModelTask
- func (c *Client) TaskTypeTakeIn(ctx context.Context, tx *gorm.DB, customId, Type string) GormModelTask
- func (c *Client) TaskTypeTakeSuccess(ctx context.Context, tx *gorm.DB, customId, Type string) GormModelTask
- func (c *Client) TaskTypeTakeTimeout(ctx context.Context, tx *gorm.DB, customId, Type string) GormModelTask
- func (c *Client) TaskTypeTakeWait(ctx context.Context, tx *gorm.DB, customId, Type string) GormModelTask
- func (c *Client) Unlock(ctx context.Context, info *GormModelTask, id any) error
- func (c *Client) UnlockCustomId(ctx context.Context, info *GormModelTask) error
- func (c *Client) UnlockId(ctx context.Context, info *GormModelTask) error
- func (c *Client) UpdateFrequency(ctx context.Context, tx *gorm.DB, id uint, frequency int64) error
- type ConfigCreateInCustomId
- type ConfigCreateInCustomIdMaxNumber
- type ConfigCreateInCustomIdMaxNumberOnly
- type ConfigCreateInCustomIdOnly
- type ConfigCreateWaitCustomId
- type Cron
- func (c *Cron) AddFunc(spec string, cmd func()) (cron.EntryID, error)
- func (c *Cron) AddJob(spec string, cmd cron.Job) (cron.EntryID, error)
- func (c *Cron) AddTask(name string, spec string, cmd func()) (cron.EntryID, error)
- func (c *Cron) Entry(id cron.EntryID) cron.Entry
- func (c *Cron) GetDrive() *cron.Cron
- func (c *Cron) List() []cron.EntryID
- func (c *Cron) ListShow()
- func (c *Cron) ListTask()
- func (c *Cron) PrintNameTask(id cron.EntryID, name string, content ...string)
- func (c *Cron) PrintTask(id cron.EntryID, content ...string)
- func (c *Cron) QueryInfo(id cron.EntryID) (cron.EntryID, string)
- func (c *Cron) QueryTask(id cron.EntryID) cron.Entry
- func (c *Cron) Remove(id cron.EntryID)
- func (c *Cron) RemoveTask(id cron.EntryID)
- func (c *Cron) RunListShow(spec string)
- func (c *Cron) RunListTask(spec string)
- func (c *Cron) Start()
- func (c *Cron) Stop() context.Context
- type CronOption
- type GormModelTask
- type GormModelTaskLog
- type Hour
- type HourInterval
- type Minutes
- type PubSubClient
- func (c *PubSubClient) DbRunSingleTask(ctx context.Context, message string, ...)
- func (c *PubSubClient) PSubscribe(ctx context.Context, channel ...string) *redis.PubSub
- func (c *PubSubClient) Publish(ctx context.Context, channel string, message interface{}) error
- func (c *PubSubClient) Subscribe(ctx context.Context, channel ...string) *redis.PubSub
- type Seconds
- type SubscribeResult
- type TaskCustomHelper
- func (th *TaskCustomHelper) EndRunTaskList()
- func (th *TaskCustomHelper) GetTaskList() []*TaskCustomHelperTaskList
- func (th *TaskCustomHelper) QueryTaskList(rootCtx context.Context, ...) (isContinue bool)
- func (th *TaskCustomHelper) RunMultipleTask(rootCtx context.Context, wait int64, ...)
- func (th *TaskCustomHelper) RunSingleTask(rootCtx context.Context, task *TaskCustomHelperTaskList, ...)
- type TaskCustomHelperTaskList
- type TaskHelper
- func (th *TaskHelper) EndRunTaskList()
- func (th *TaskHelper) FilterTaskList(rootCtx context.Context, isMandatoryIp bool, specifyIp string) (isContinue bool)
- func (th *TaskHelper) GetTaskList() []*GormModelTask
- func (th *TaskHelper) QueryTaskList(rootCtx context.Context, ...) (isContinue bool)
- func (th *TaskHelper) RunMultipleTask(rootCtx context.Context, wait int64, ...)
- func (th *TaskHelper) RunSingleTask(rootCtx context.Context, task *GormModelTask, ...)
- type TaskHelperOption
- type TaskHelperRunSingleTaskResponse
- type TaskLockOperation
- func (tlo *TaskLockOperation) Lock(ctx context.Context, id any) error
- func (tlo *TaskLockOperation) LockCustomId(ctx context.Context) error
- func (tlo *TaskLockOperation) LockForever(ctx context.Context, id any) error
- func (tlo *TaskLockOperation) LockForeverCustomId(ctx context.Context) error
- func (tlo *TaskLockOperation) LockForeverId(ctx context.Context) error
- func (tlo *TaskLockOperation) LockId(ctx context.Context) error
- func (tlo *TaskLockOperation) Unlock(ctx context.Context, id any) error
- func (tlo *TaskLockOperation) UnlockCustomId(ctx context.Context) error
- func (tlo *TaskLockOperation) UnlockId(ctx context.Context) error
Constants ¶
const ( // CodeAbnormal 异常 CodeAbnormal = 0 // CodeError 失败 CodeError = http.StatusInternalServerError // CodeSuccess 成功 CodeSuccess = http.StatusOK // CodeEnd 结束 CodeEnd = http.StatusCreated )
const ( // TASK_IN 任务运行 TASK_IN = "IN" // TASK_SUCCESS 任务完成 TASK_SUCCESS = "SUCCESS" // TASK_ERROR 任务异常 TASK_ERROR = "ERROR" // TASK_TIMEOUT 任务超时 TASK_TIMEOUT = "TIMEOUT" // TASK_WAIT 任务等待 TASK_WAIT = "WAIT" )
const (
SpecifyIpNull = "0.0.0.0"
)
const (
Version = "1.0.161"
)
Variables ¶
This section is empty.
Functions ¶
func EntTaskAnnotations ¶ added in v1.0.161
func EntTaskAnnotations() []schema.Annotation
EntTaskAnnotations 任务
func EntTaskLogAnnotations ¶ added in v1.0.161
func EntTaskLogAnnotations() []schema.Annotation
EntTaskLogAnnotations 任务日志
func EntTaskLogIndexes ¶ added in v1.0.161
EntTaskLogIndexes 任务日志
func NewTraceStartSpan ¶
NewTraceStartSpan 开始OpenTelemetry链路追踪状态
func SetRedisKeyValue ¶
func SetRedisKeyValue(ctx context.Context, taskType string) (context.Context, string, any, time.Duration)
SetRedisKeyValue 返回设置Redis键值
func SetRedisKeyValueExpiration ¶
func SetRedisKeyValueExpiration(ctx context.Context, taskType string, expiration int64) (context.Context, string, any, time.Duration)
SetRedisKeyValueExpiration 返回设置Redis键值,有过分时间
func TraceGetSpanID ¶
TraceGetSpanID 获取OpenTelemetry链路追踪SpanID
func TraceGetTraceID ¶
TraceGetTraceID 获取OpenTelemetry链路追踪TraceID
func TraceRecordError ¶
func TraceRecordError(ctx context.Context, err error, options ...trace.EventOption)
TraceRecordError 记录OpenTelemetry链路追踪错误
func TraceSetAttributes ¶
TraceSetAttributes 设置OpenTelemetry链路追踪属性
func TraceSetStatus ¶
TraceSetStatus 设置OpenTelemetry链路追踪状态
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 实例
func (*Client) ConfigGormClientFun ¶
func (c *Client) ConfigGormClientFun(ctx context.Context, client *gorm.DB, taskTableName string, taskLogStatus bool, taskLogTableName string) error
ConfigGormClientFun GORM配置
func (*Client) ConfigRedisClientFun ¶
func (c *Client) ConfigRedisClientFun(ctx context.Context, client *redis.Client, lockKeyPrefix string, lockKeySeparator string, cornKeyPrefix string, cornKeyCustom string) error
ConfigRedisClientFun REDIS配置 lockKeyPrefix 锁Key前缀 xxx_lock lockKeySeparator 锁Key分隔符 : cornKeyPrefix 任务Key前缀 xxx_cron cornKeyCustom 任务Key自定义 xxx_cron_自定义 xxx_cron_自定义_*
func (*Client) CreateInCustomId ¶
func (c *Client) CreateInCustomId(ctx context.Context, config *ConfigCreateInCustomId) error
CreateInCustomId 创建正在运行任务
func (*Client) CreateInCustomIdMaxNumber ¶
func (c *Client) CreateInCustomIdMaxNumber(ctx context.Context, config *ConfigCreateInCustomIdMaxNumber) error
CreateInCustomIdMaxNumber 创建正在运行任务并限制数量
func (*Client) CreateInCustomIdMaxNumberOnly ¶
func (c *Client) CreateInCustomIdMaxNumberOnly(ctx context.Context, config *ConfigCreateInCustomIdMaxNumberOnly) error
CreateInCustomIdMaxNumberOnly 创建正在运行唯一任务并限制数量
func (*Client) CreateInCustomIdOnly ¶
func (c *Client) CreateInCustomIdOnly(ctx context.Context, config *ConfigCreateInCustomIdOnly) error
CreateInCustomIdOnly 创建正在运行唯一任务
func (*Client) CreateWaitCustomId ¶
func (c *Client) CreateWaitCustomId(ctx context.Context, config *ConfigCreateWaitCustomId) error
CreateWaitCustomId 创建正在运行任务
func (*Client) Filter ¶
func (c *Client) Filter(ctx context.Context, isMandatoryIp bool, specifyIp string, tasks []GormModelTask, isPrint bool) (newTasks []GormModelTask)
Filter 过滤 ctx 上下文 isMandatoryIp 强制当前ip specifyIp 指定Ip tasks 过滤前的数据 newTasks 过滤后的数据
func (*Client) GetIssueAddress ¶
func (c *Client) GetIssueAddress(ctx context.Context, workers []string, v *GormModelTask) (string, error)
GetIssueAddress 获取下发地址 workers 在线列表 v 任务信息 --- address 下发地址 err 错误信息
func (*Client) GetSubscribeAddress ¶
GetSubscribeAddress 获取订阅地址
func (*Client) GetSubscribeClientList ¶
GetSubscribeClientList 获取在线的客户端
func (*Client) GormTaskLogDelete ¶
GormTaskLogDelete 删除
func (*Client) GormTaskLogErrorDelete ¶
GormTaskLogErrorDelete 删除任务异常
func (*Client) GormTaskLogInDelete ¶
GormTaskLogInDelete 删除任务运行
func (*Client) GormTaskLogRecord ¶
func (c *Client) GormTaskLogRecord(ctx context.Context, task GormModelTask, runId string, taskResultCode int, taskResultDesc string)
GormTaskLogRecord 记录
func (*Client) GormTaskLogSuccessDelete ¶
GormTaskLogSuccessDelete 删除任务完成
func (*Client) GormTaskLogTimeoutDelete ¶
GormTaskLogTimeoutDelete 删除任务超时
func (*Client) GormTaskLogWaitDelete ¶
GormTaskLogWaitDelete 删除任务等待
func (*Client) LockCustomId ¶
LockCustomId 上锁
func (*Client) LockForever ¶
LockForever 永远上锁
func (*Client) LockForeverCustomId ¶
LockForeverCustomId 永远上锁
func (*Client) LockForeverId ¶
LockForeverId 永远上锁
func (*Client) NewLock ¶
func (c *Client) NewLock(task *GormModelTask) (*TaskLockOperation, error)
func (*Client) PSubscribe ¶
func (c *Client) PSubscribe(ctx context.Context) SubscribeResult
PSubscribe 订阅,支持通配符匹配(ch_user_*)
func (*Client) Run ¶
func (c *Client) Run(ctx context.Context, task GormModelTask, taskResultCode int, taskResultDesc string)
Run 运行
func (*Client) StartCronClean ¶
func (c *Client) StartCronClean(ctx context.Context, cr *cron.Cron, cp string, hour int64) (cron.EntryID, error)
StartCronClean 定时清理任务日志
func (*Client) StartHandle ¶
func (*Client) StartTaskCustom ¶
func (c *Client) StartTaskCustom(ctx context.Context, tx *gorm.DB, customId string, customSequence int64) error
StartTaskCustom 任务启动自定义
func (*Client) Subscribe ¶
func (c *Client) Subscribe(ctx context.Context) SubscribeResult
Subscribe 订阅
func (*Client) TaskFindAll ¶
func (c *Client) TaskFindAll(ctx context.Context, tx *gorm.DB, frequency int64) (results []GormModelTask)
TaskFindAll 查询多任务
func (*Client) TaskFindAllError ¶
func (c *Client) TaskFindAllError(ctx context.Context, tx *gorm.DB, frequency int64) []GormModelTask
TaskFindAllError 查询多任务 - 任务异常
func (*Client) TaskFindAllErrorType ¶
func (c *Client) TaskFindAllErrorType(ctx context.Context, tx *gorm.DB, Type string) []GormModelTask
TaskFindAllErrorType 查询多任务 - 任务异常
func (*Client) TaskFindAllIn ¶
TaskFindAllIn 查询多任务 - 任务运行
func (*Client) TaskFindAllInType ¶
TaskFindAllInType 查询多任务 - 任务运行
func (*Client) TaskFindAllSuccess ¶
func (c *Client) TaskFindAllSuccess(ctx context.Context, tx *gorm.DB, frequency int64) []GormModelTask
TaskFindAllSuccess 查询多任务 - 任务完成
func (*Client) TaskFindAllSuccessType ¶
func (c *Client) TaskFindAllSuccessType(ctx context.Context, tx *gorm.DB, Type string) []GormModelTask
TaskFindAllSuccessType 查询多任务 - 任务完成
func (*Client) TaskFindAllTimeout ¶
func (c *Client) TaskFindAllTimeout(ctx context.Context, tx *gorm.DB, frequency int64) []GormModelTask
TaskFindAllTimeout 查询多任务 - 任务超时
func (*Client) TaskFindAllTimeoutType ¶
func (c *Client) TaskFindAllTimeoutType(ctx context.Context, tx *gorm.DB, Type string) []GormModelTask
TaskFindAllTimeoutType 查询多任务 - 任务超时
func (*Client) TaskFindAllType ¶
func (c *Client) TaskFindAllType(ctx context.Context, tx *gorm.DB, Type string, frequency int64) (results []GormModelTask)
TaskFindAllType 查询多任务
func (*Client) TaskFindAllWait ¶
TaskFindAllWait 查询多任务 - 任务等待
func (*Client) TaskFindAllWaitType ¶
TaskFindAllWaitType 查询多任务 - 任务等待
func (*Client) TaskTakeError ¶
TaskTakeError 查询单任务 - 任务异常
func (*Client) TaskTakeId ¶
TaskTakeId 编号查询任务
func (*Client) TaskTakeIn ¶
TaskTakeIn 查询单任务 - 任务运行
func (*Client) TaskTakeSuccess ¶
TaskTakeSuccess 查询单任务 - 任务完成
func (*Client) TaskTakeTimeout ¶
TaskTakeTimeout 查询单任务 - 任务超时
func (*Client) TaskTakeWait ¶
TaskTakeWait 查询单任务 - 任务等待
func (*Client) TaskTypeTake ¶
func (c *Client) TaskTypeTake(ctx context.Context, tx *gorm.DB, customId, Type string) (result GormModelTask)
TaskTypeTake 查询单任务
func (*Client) TaskTypeTakeError ¶
func (c *Client) TaskTypeTakeError(ctx context.Context, tx *gorm.DB, customId, Type string) GormModelTask
TaskTypeTakeError 查询单任务 - 任务异常
func (*Client) TaskTypeTakeIn ¶
func (c *Client) TaskTypeTakeIn(ctx context.Context, tx *gorm.DB, customId, Type string) GormModelTask
TaskTypeTakeIn 查询单任务 - 任务运行
func (*Client) TaskTypeTakeSuccess ¶
func (c *Client) TaskTypeTakeSuccess(ctx context.Context, tx *gorm.DB, customId, Type string) GormModelTask
TaskTypeTakeSuccess 查询单任务 - 任务完成
func (*Client) TaskTypeTakeTimeout ¶
func (c *Client) TaskTypeTakeTimeout(ctx context.Context, tx *gorm.DB, customId, Type string) GormModelTask
TaskTypeTakeTimeout 查询单任务 - 任务超时
func (*Client) TaskTypeTakeWait ¶
func (c *Client) TaskTypeTakeWait(ctx context.Context, tx *gorm.DB, customId, Type string) GormModelTask
TaskTypeTakeWait 查询单任务 - 任务等待
func (*Client) UnlockCustomId ¶
func (c *Client) UnlockCustomId(ctx context.Context, info *GormModelTask) error
UnlockCustomId 解锁
type ConfigCreateInCustomId ¶
type ConfigCreateInCustomId struct { Tx *gorm.DB // 驱动 Params string // 参数 Frequency int64 // 频率(秒单位) Spec string // cron表达式 CustomID string // 自定义编号 CustomSequence int64 // 自定义顺序 Type string // 类型 TypeName string // 类型名称 SpecifyIP string // 指定IP CurrentIP string // 当前IP }
ConfigCreateInCustomId 创建正在运行任务
type ConfigCreateInCustomIdMaxNumber ¶
type ConfigCreateInCustomIdMaxNumber struct { Tx *gorm.DB // 驱动 Params string // 参数 Frequency int64 // 频率(秒单位) Spec string // cron表达式 MaxNumber int64 // 最大次数 CustomID string // 自定义编号 CustomSequence int64 // 自定义顺序 Type string // 类型 TypeName string // 类型名称 SpecifyIP string // 指定IP CurrentIP string // 当前IP }
ConfigCreateInCustomIdMaxNumber 创建正在运行任务并限制数量
type ConfigCreateInCustomIdMaxNumberOnly ¶
type ConfigCreateInCustomIdMaxNumberOnly struct { Tx *gorm.DB // 驱动 Params string // 参数 Frequency int64 // 频率(秒单位) Spec string // cron表达式 MaxNumber int64 // 最大次数 CustomID string // 自定义编号 CustomSequence int64 // 自定义顺序 Type string // 类型 TypeName string // 类型名称 SpecifyIP string // 指定IP CurrentIP string // 当前IP }
ConfigCreateInCustomIdMaxNumberOnly 创建正在运行唯一任务并限制数量
type ConfigCreateInCustomIdOnly ¶
type ConfigCreateInCustomIdOnly struct { Tx *gorm.DB // 驱动 Params string // 参数 Frequency int64 // 频率(秒单位) Spec string // cron表达式 CustomID string // 自定义编号 CustomSequence int64 // 自定义顺序 Type string // 类型 TypeName string // 类型名称 SpecifyIP string // 指定IP CurrentIP string // 当前IP }
ConfigCreateInCustomIdOnly 创建正在运行唯一任务
type ConfigCreateWaitCustomId ¶
type ConfigCreateWaitCustomId struct { Tx *gorm.DB // 驱动 Params string // 参数 Frequency int64 // 频率(秒单位) Spec string // cron表达式 CustomID string // 自定义编号 CustomSequence int64 // 自定义顺序 Type string // 类型 TypeName string // 类型名称 SpecifyIP string // 指定IP CurrentIP string // 当前IP }
ConfigCreateWaitCustomId 创建正在运行任务
type Cron ¶
type Cron struct {
// contains filtered or unexported fields
}
Cron 定时任务管理器
func NewCronWithSeconds ¶
func NewCronWithSeconds(opts ...CronOption) *Cron
func (*Cron) PrintNameTask ¶
PrintNameTask 日志任务
type CronOption ¶
type CronOption func(*Cron)
type GormModelTask ¶
type GormModelTask struct { ID uint `gorm:"primaryKey;comment:记录编号" json:"id,omitempty"` // 记录编号 Status string `gorm:"index;comment:状态码" json:"status,omitempty"` // 状态码 StatusDesc string `gorm:"comment:状态描述" json:"status_desc,omitempty"` // 状态描述 Params string `gorm:"comment:参数" json:"params,omitempty"` // 参数 Frequency int64 `gorm:"index;comment:频率(秒单位)" json:"frequency,omitempty"` // 频率(秒单位) Spec string `gorm:"index;comment:cron表达式" json:"spec,omitempty"` // cron表达式 Number int64 `gorm:"comment:当前次数" json:"number,omitempty"` // 当前次数 MaxNumber int64 `gorm:"comment:最大次数" json:"max_number,omitempty"` // 最大次数 RunID string `gorm:"comment:执行编号" json:"run_id,omitempty"` // 执行编号 CustomID string `gorm:"index;comment:自定义编号" json:"custom_id,omitempty"` // 自定义编号 CustomSequence int64 `gorm:"comment:自定义顺序" json:"custom_sequence,omitempty"` // 自定义顺序 Type string `gorm:"index;comment:类型" json:"type,omitempty"` // 类型 TypeName string `gorm:"comment:类型名称" json:"type_name,omitempty"` // 类型名称 CreatedIP string `gorm:"default:0.0.0.0;comment:创建外网IP" json:"created_ip,omitempty"` // 创建外网IP SpecifyIP string `gorm:"default:0.0.0.0;index;comment:指定外网IP" json:"specify_ip,omitempty"` // 指定外网IP UpdatedIP string `gorm:"default:0.0.0.0;comment:更新外网IP" json:"updated_ip,omitempty"` // 更新外网IP Result string `gorm:"comment:结果" json:"result,omitempty"` // 结果 NextRunTime time.Time `gorm:"comment:下次运行时间" json:"next_run_time,omitempty"` // 下次运行时间 CreatedAt time.Time `gorm:"autoCreateTime;comment:创建时间" json:"created_at,omitempty"` // 创建时间 UpdatedAt time.Time `gorm:"autoUpdateTime;comment:更新时间" json:"updated_at,omitempty"` // 更新时间 DeletedAt gorm.DeletedAt `gorm:"index;comment:删除时间" json:"deleted_at,omitempty"` // 删除时间 }
GormModelTask 任务
type GormModelTaskLog ¶
type GormModelTaskLog struct { LogID uint `gorm:"primaryKey;comment:【日志】编号" json:"log_id"` // 【日志】编号 LogTime time.Time `gorm:"autoCreateTime;index;comment:【日志】时间" json:"log_time"` // 【日志】时间 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"` //【任务】执行结果 SystemInsideIP string `gorm:"default:0.0.0.0;comment:【系统】内网IP" json:"system_inside_ip,omitempty"` //【系统】内网IP SystemOutsideIP string `gorm:"default:0.0.0.0;comment:【系统】外网IP" json:"system_outside_ip"` //【系统】外网IP }
GormModelTaskLog 任务日志
type HourInterval ¶
type HourInterval struct {
// contains filtered or unexported fields
}
HourInterval 每隔n小时执行一次
type PubSubClient ¶
type PubSubClient struct {
// contains filtered or unexported fields
}
func NewPubSub ¶
func NewPubSub(ctx context.Context, client *redis.Client) *PubSubClient
func (*PubSubClient) DbRunSingleTask ¶
func (c *PubSubClient) DbRunSingleTask(ctx context.Context, message string, executionCallback func(ctx context.Context, task *GormModelTask) (runCode int, runDesc string), updateCallback func(ctx context.Context, task *GormModelTask, result *TaskHelperRunSingleTaskResponse) (err error))
DbRunSingleTask 运行单个任务 ctx 链路追踪的上下文 message 任务json编码 executionCallback 执行任务回调函数 返回 runCode=状态 runDesc=描述 updateCallback 执行更新回调函数
func (*PubSubClient) PSubscribe ¶
func (c *PubSubClient) PSubscribe(ctx context.Context, channel ...string) *redis.PubSub
PSubscribe 订阅,支持通配符匹配(ch_user_*)
type SubscribeResult ¶
type SubscribeResult struct { Message *redis.PubSub // contains filtered or unexported fields }
type TaskCustomHelper ¶
type TaskCustomHelper struct { Ctx context.Context // [启动]上下文 Span trace.Span // [启动]链路追踪 // contains filtered or unexported fields }
func NewTaskCustomHelper ¶
func NewTaskCustomHelper(rootCtx context.Context, taskType string, opts ...TaskHelperOption) *TaskCustomHelper
NewTaskCustomHelper 任务帮助 rootCtx 链路追踪的上下文 taskType 任务类型 logIsDebug 日志是否启动 traceIsFilter 链路追踪是否过滤
func (*TaskCustomHelper) EndRunTaskList ¶
func (th *TaskCustomHelper) EndRunTaskList()
EndRunTaskList 结束运行任务列表并停止OpenTelemetry链路追踪
func (*TaskCustomHelper) GetTaskList ¶
func (th *TaskCustomHelper) GetTaskList() []*TaskCustomHelperTaskList
GetTaskList 请在QueryTaskList之后获取任务列表
func (*TaskCustomHelper) QueryTaskList ¶
func (th *TaskCustomHelper) QueryTaskList(rootCtx context.Context, isRunCallback func(ctx context.Context, keyName string) (isUse bool, result *redis.StringCmd), listCallback func(ctx context.Context, taskType string) []*TaskCustomHelperTaskList) (isContinue bool)
QueryTaskList 通过回调函数获取任务列表 rootCtx 链路追踪的上下文 isRunCallback 任务列表回调函数 返回 是否使用 任务列表 listCallback 任务回调函数 返回 任务列表 newTaskLists 新的任务列表 isContinue 是否继续
func (*TaskCustomHelper) RunMultipleTask ¶
func (th *TaskCustomHelper) RunMultipleTask(rootCtx context.Context, wait int64, executionCallback func(ctx context.Context, task *TaskCustomHelperTaskList) (err error), startCallback func(ctx context.Context, taskType string) (err error), endCallback func(ctx context.Context, taskType string))
RunMultipleTask 运行多个任务 rootCtx 链路追踪的上下文 wait 等待时间(秒) executionCallback 执行任务回调函数 startCallback 开始任务回调函数 endCallback 结束任务回调函数
func (*TaskCustomHelper) RunSingleTask ¶
func (th *TaskCustomHelper) RunSingleTask(rootCtx context.Context, task *TaskCustomHelperTaskList, executionCallback func(ctx context.Context, task *TaskCustomHelperTaskList) (err error))
RunSingleTask 运行单个任务 rootCtx 链路追踪的上下文 task 任务 executionCallback 执行任务回调函数
type TaskCustomHelperTaskList ¶
type TaskCustomHelperTaskList struct { TaskID string `json:"task_id,omitempty"` // 任务编号 TaskName string `json:"task_name,omitempty"` // 任务名称 TaskParams string `json:"task_params,omitempty"` // 任务参数 CustomID string `json:"custom_id,omitempty"` // 自定义编号 CustomContent string `json:"custom_content,omitempty"` // 自定义内容 }
type TaskHelper ¶
type TaskHelper struct { Ctx context.Context // [启动]上下文 Span trace.Span // [启动]链路追踪 // contains filtered or unexported fields }
func NewTaskHelper ¶
func NewTaskHelper(rootCtx context.Context, taskType string, opts ...TaskHelperOption) *TaskHelper
NewTaskHelper 任务帮助 ctx 链路追踪的上下文 taskType 任务类型 logIsDebug 日志是否启动 traceIsFilter 链路追踪是否过滤
func (*TaskHelper) EndRunTaskList ¶
func (th *TaskHelper) EndRunTaskList()
EndRunTaskList 结束运行任务列表并停止OpenTelemetry链路追踪
func (*TaskHelper) FilterTaskList ¶
func (th *TaskHelper) FilterTaskList(rootCtx context.Context, isMandatoryIp bool, specifyIp string) (isContinue bool)
FilterTaskList 过滤任务列表 rootCtx 链路追踪的上下文 isMandatoryIp 强制当前ip specifyIp 指定Ip isContinue 是否继续
func (*TaskHelper) GetTaskList ¶
func (th *TaskHelper) GetTaskList() []*GormModelTask
GetTaskList 请在FilterTaskList之后获取任务列表
func (*TaskHelper) QueryTaskList ¶
func (th *TaskHelper) QueryTaskList(rootCtx context.Context, isRunCallback func(ctx context.Context, keyName string) (isUse bool, result *redis.StringCmd), listCallback func(ctx context.Context, taskType string) []*GormModelTask) (isContinue bool)
QueryTaskList 通过回调函数获取任务列表 rootCtx 链路追踪的上下文 isRunCallback 任务列表回调函数 返回 是否使用 任务列表 listCallback 任务回调函数 返回 任务列表 newTaskLists 新的任务列表 isContinue 是否继续
func (*TaskHelper) RunMultipleTask ¶
func (th *TaskHelper) RunMultipleTask(rootCtx context.Context, wait int64, executionCallback func(ctx context.Context, task *GormModelTask) (runCode int, runDesc string), updateCallback func(ctx context.Context, task *GormModelTask, result *TaskHelperRunSingleTaskResponse), startCallback func(ctx context.Context, taskType string) (err error), endCallback func(ctx context.Context, taskType string))
RunMultipleTask 运行多个任务 rootCtx 链路追踪的上下文 wait 等待时间(秒) executionCallback 执行任务回调函数 返回 runCode=状态 runDesc=描述 updateCallback 执行更新回调函数 startCallback 开始任务回调函数 endCallback 结束任务回调函数
func (*TaskHelper) RunSingleTask ¶
func (th *TaskHelper) RunSingleTask(rootCtx context.Context, task *GormModelTask, executionCallback func(ctx context.Context, task *GormModelTask) (runCode int, runDesc string), updateCallback func(ctx context.Context, task *GormModelTask, result *TaskHelperRunSingleTaskResponse))
RunSingleTask 运行单个任务 rootCtx 链路追踪的上下文 task 任务 executionCallback 执行任务回调函数 返回 runCode=状态 runDesc=描述 updateCallback 执行更新回调函数
type TaskHelperOption ¶
type TaskHelperOption interface {
// contains filtered or unexported methods
}
func TaskHelperWithDebug ¶
func TaskHelperWithDebug(is bool) TaskHelperOption
TaskHelperWithDebug 设置日志是否打印
func TaskHelperWithFilter ¶
func TaskHelperWithFilter(is bool, keyName string, keyValue string) TaskHelperOption
TaskHelperWithFilter 设置链路追踪是否过滤
type TaskLockOperation ¶
type TaskLockOperation struct {
// contains filtered or unexported fields
}
func (*TaskLockOperation) Lock ¶
func (tlo *TaskLockOperation) Lock(ctx context.Context, id any) error
Lock 上锁
func (*TaskLockOperation) LockCustomId ¶
func (tlo *TaskLockOperation) LockCustomId(ctx context.Context) error
LockCustomId 上锁
func (*TaskLockOperation) LockForever ¶
func (tlo *TaskLockOperation) LockForever(ctx context.Context, id any) error
LockForever 永远上锁
func (*TaskLockOperation) LockForeverCustomId ¶
func (tlo *TaskLockOperation) LockForeverCustomId(ctx context.Context) error
LockForeverCustomId 永远上锁
func (*TaskLockOperation) LockForeverId ¶
func (tlo *TaskLockOperation) LockForeverId(ctx context.Context) error
LockForeverId 永远上锁
func (*TaskLockOperation) LockId ¶
func (tlo *TaskLockOperation) LockId(ctx context.Context) error
LockId 上锁
func (*TaskLockOperation) Unlock ¶
func (tlo *TaskLockOperation) Unlock(ctx context.Context, id any) error
Unlock 解锁
func (*TaskLockOperation) UnlockCustomId ¶
func (tlo *TaskLockOperation) UnlockCustomId(ctx context.Context) error
UnlockCustomId 解锁
Source Files ¶
- client.cofing.go
- client.const.go
- client.go
- client.opentelemetry.go
- create_in.go
- create_wait.go
- cron.go
- cron_clean.go
- cron_get.go
- cron_option.go
- cron_run.go
- cron_spec.go
- ent_model.go
- get.go
- gorm_model_task.go
- gorm_model_task_log.go
- jobs.go
- lock.go
- lock_custom_id.go
- lock_id.go
- redis.go
- redis.helper.go
- redis.pubsub.go
- redis_get.go
- task.custom.helper.go
- task.custom.helper.params.go
- task.filter.go
- task.helper.go
- task.helper.options.go
- task.run.go
- task_lock.go
- version.go