delayqueue

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RedisPool RedisPool连接池实例
	RedisPool *redis.Pool
)

Functions

func Init

func Init()

Init 初始化延时队列

func Push

func Push(job Job) error

Push 添加一个Job到队列中

func Remove

func Remove(jobId string) error

Remove 删除Job

Types

type BucketItem

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

BucketItem bucket中的元素

type Job

type Job struct {
	Topic string `json:"topic" msgpack:"1"`
	Id    string `json:"id" msgpack:"2"`    // job唯一标识ID
	Delay int64  `json:"delay" msgpack:"3"` // 延迟时间, unix时间戳
	TTR   int64  `json:"ttr" msgpack:"4"`
	Body  string `json:"body" msgpack:"5"`
}

Job 使用msgpack序列化后保存到Redis,减少内存占用

func Get

func Get(jobId string) (*Job, error)

Get 查询Job

func Pop

func Pop(topics []string) (*Job, error)

Pop 轮询获取Job

Jump to

Keyboard shortcuts

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