task

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAsynqClient

func NewAsynqClient(conf redis.Conf) *asynq.Client

func NewAsynqServer

func NewAsynqServer(log *zap.SugaredLogger, conf redis.Conf, scfg AsynqServerConfig) *asynq.Server

Types

type AsyncTask

type AsyncTask struct {
	TaskType  TaskType      // 任务类型
	DelaySec  time.Duration // 延时多少秒开始执行
	ProcessAt time.Time     // 指定时间执行
	MaxRetry  int           // 重试次数
	Payload   interface{}   // 作务载体
	TaskId    string        // 任务唯一ID
	UniqueTTL time.Duration // 保持任务唯一的时间段
	QueueName TaskQueue     // 队列名,优先级不同
}

type AsynqServerConfig

type AsynqServerConfig struct {
	Concurrency    int            `yaml:"concurrency"`
	Queues         map[string]int `yaml:"queues"`
	StrictPriority bool           `yaml:"strictPriority"`
}

type AsynqTaskScheduler

type AsynqTaskScheduler struct {
	// contains filtered or unexported fields
}

AsynqTaskScheduler https://github.com/hibiken/asynq/wiki/Getting-Started

func NewAsynqTaskScheduler

func NewAsynqTaskScheduler(log *zap.SugaredLogger, client *asynq.Client) *AsynqTaskScheduler

func (AsynqTaskScheduler) Schedule

func (scheduler AsynqTaskScheduler) Schedule(t *AsyncTask) error

type TaskQueue

type TaskQueue string // 队列名
const (
	AQ_CRITICAL TaskQueue = "critical" // 优先级最高
	AQ_DEFAULT  TaskQueue = "default"  // 默认
	AQ_LOW      TaskQueue = "low"      // 最低的
)

type TaskType

type TaskType string // 异步任务类型

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL