Documentation ¶
Index ¶
- Constants
- Variables
- func WithCallback(s string) func(*Options)
- func WithClearArchived(second int) func(*Options)
- func WithConcurrencyNum(s int) func(*Options)
- func WithGroup(s string) func(*Options)
- func WithGroupGracePeriod(second int) func(*Options)
- func WithGroupMaxDelay(second int) func(*Options)
- func WithGroupMaxSize(second int) func(*Options)
- func WithHandler(fun func(ctx context.Context, p Payload) error) func(*Options)
- func WithHandlerAggregator(fun func(ctx context.Context, task *asynq.Task) error) func(*Options)
- func WithHandlerNeedWorker(fun func(worker Worker, ctx context.Context, p Payload) error) func(*Options)
- func WithMaxRetry(count int) func(*Options)
- func WithRedisLinkMode(s string) func(*Options)
- func WithRedisPeriodKey(s string) func(*Options)
- func WithRedisUri(s string) func(*Options)
- func WithRetention(second int) func(*Options)
- func WithRunAt(at time.Time) func(*RunOptions)
- func WithRunCtx(ctx context.Context) func(*RunOptions)
- func WithRunExpr(s string) func(*RunOptions)
- func WithRunGroup(s string) func(*RunOptions)
- func WithRunIn(in time.Duration) func(*RunOptions)
- func WithRunMaxRetry(count int) func(*RunOptions)
- func WithRunNow(flag bool) func(*RunOptions)
- func WithRunPayload(s []byte) func(*RunOptions)
- func WithRunReplace(flag bool) func(*RunOptions)
- func WithRunRetention(second int) func(*RunOptions)
- func WithRunTimeout(second int) func(*RunOptions)
- func WithRunUuid(s string) func(*RunOptions)
- func WithTimeout(second int) func(*Options)
- func WithUseAggregator(s bool) func(*Options)
- type BaseProcess
- type Options
- type Payload
- type Process
- type ProcessConfig
- type RunOptions
- type Scheduled
- type Worker
Constants ¶
View Source
const ( DefaultProcess = "defaultProcess" // 默认处理 AggregateProcess = "aggregateProcess" // 聚合处理 CronProcess = "cronProcess" // 定时任务 )
Variables ¶
View Source
var ( ErrUuidNil = fmt.Errorf("uuid is empty") ErrRedisNil = fmt.Errorf("redis is empty") ErrRedisInvalid = fmt.Errorf("redis is invalid") ErrExprInvalid = fmt.Errorf("expr is invalid") ErrSaveCron = fmt.Errorf("save cron failed") ErrHttpCallbackInvalidStatusCode = fmt.Errorf("http callback invalid status code") )
Functions ¶
func WithClearArchived ¶
WithClearArchived 清除已存档任务的间隔,默认为 300 秒
func WithConcurrencyNum ¶
WithConcurrencyNum 设置任务处理器的并发数
func WithGroupGracePeriod ¶
WithGroupGracePeriod 每多少秒聚合一次
func WithGroupMaxDelay ¶
WithGroupMaxDelay 最晚多少秒聚合一次
func WithHandler ¶
WithHandler 设置任务的回调处理器
func WithHandlerAggregator ¶
WithHandleAggregator 设置聚合任务的回调处理器
func WithHandlerNeedWorker ¶
func WithHandlerNeedWorker(fun func(worker Worker, ctx context.Context, p Payload) error) func(*Options)
WithHandlerNeedWorker 设置需要Worker参数的任务处理函数
func WithRedisLinkMode ¶
WithRedisLinkMode 设置redis连接模式
func WithRedisPeriodKey ¶
WithRedisPeriodKey 设置redis周期任务key
func WithRedisUri ¶
WithRedisUri 设置redis连接地址,默认值redis://127.0.0.1:6379/0
func WithRetention ¶
WithRetention 成功任务存储时间,默认 60 秒,如果提供此选项,任务将在成功处理后作为已完成任务存储
func WithRunExpr ¶
func WithRunExpr(s string) func(*RunOptions)
WithRunExpr Cron表达式, 最小单位1分钟, 参见gorhill/cronexpr
func WithRunMaxRetry ¶
func WithRunMaxRetry(count int) func(*RunOptions)
WithRunMaxRetry 最大重试次数, 任务回调发生error会重试,默认3次
func WithRunReplace ¶
func WithRunReplace(flag bool) func(*RunOptions)
WithRunReplace 当uid重复时,删除旧的并创建新的
func WithRunRetention ¶
func WithRunRetention(second int) func(*RunOptions)
WithRunRetention 任务过期时间,默认60秒
Types ¶
type BaseProcess ¶
type BaseProcess struct{}
func (*BaseProcess) GetProcessConfig ¶
func (q *BaseProcess) GetProcessConfig() *ProcessConfig
func (*BaseProcess) GetTopic ¶
func (q *BaseProcess) GetTopic() string
func (*BaseProcess) Handle ¶
func (q *BaseProcess) Handle(ctx context.Context, p Payload) (err error)
func (*BaseProcess) HandleAggregate ¶
HandleAggregate 处理消息
type Payload ¶
type Process ¶
type Process interface { GetTopic() string GetProcessConfig() *ProcessConfig // 获取消费主题 Handle(ctx context.Context, p Payload) (err error) // 处理过程的方法 HandleAggregate(ctx context.Context, task *asynq.Task) (err error) // 处理聚合过程的方法 }
Process 任务具体处理过程接口,实现该接口即可加入到任务队列中
type ProcessConfig ¶
type RunOptions ¶
type RunOptions struct {
// contains filtered or unexported fields
}
type Scheduled ¶
type Scheduled struct {
// contains filtered or unexported fields
}
Scheduled 任务调度器
func RegisterProcess ¶
Click to show internal directories.
Click to hide internal directories.