queue

package
v0.0.0-...-cd4d371 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FailJob

type FailJob struct {
	Id   string          `json:"id"`
	Msg  string          `json:"msg"`
	Try  int             `json:"try"`
	Body json.RawMessage `json:"body"`
}

type Processor

type Processor interface {
	Process(ctx context.Context, id string, body []byte) error
}

type Queue

type Queue interface {
	//添加任务
	Add(ctx context.Context, id string, body []byte, delay time.Duration) error
	//拉取任务
	Pop(ctx context.Context) (string, []byte, error)
	//确认任务
	Ack(ctx context.Context, id string) error
	//失败任务
	Fail(ctx context.Context, id, msg string) error
	//检查延迟任务
	FetchDelay(ctx context.Context) error
}

type RQ

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

func NewRedis

func NewRedis(name string, maxTry int, rds *redis.Service) *RQ

func (*RQ) Ack

func (q *RQ) Ack(ctx context.Context, id string) error

func (*RQ) Add

func (q *RQ) Add(ctx context.Context, id string, body []byte, delay time.Duration) error

func (*RQ) Fail

func (q *RQ) Fail(ctx context.Context, id, msg string) error

func (*RQ) FetchDelay

func (q *RQ) FetchDelay(ctx context.Context) error

func (*RQ) Pop

func (q *RQ) Pop(ctx context.Context) (string, []byte, error)

type Worker

type Worker struct {
	Queue
	Processor
	// contains filtered or unexported fields
}

func New

func New(name string, q Queue, processor Processor) *Worker

func (*Worker) Consume

func (w *Worker) Consume(ctx context.Context) error

Consume 消费

func (*Worker) Limit

func (w *Worker) Limit(t time.Duration, burst int)

func (*Worker) Run

func (w *Worker) Run(ctx context.Context)

Run Run

Jump to

Keyboard shortcuts

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