delayqueue

package module
v0.0.0-...-4f72b75 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: MIT Imports: 5 Imported by: 0

README

Delay queue

How to use

TODO

  • Add logs
  • Run as a service
  • Translate all docs and comments to English

Acknowledgment

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisPool

func NewRedisPool(maxIdle int, network, address, password string) *redis.Pool

Types

type DelayQueue

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

func NewDelayQueue

func NewDelayQueue(redisPool *redis.Pool) *DelayQueue

func NewDelayQueueWithPrefix

func NewDelayQueueWithPrefix(redisPool *redis.Pool, keyPrefix string) *DelayQueue

func (*DelayQueue) DeQueue

func (q *DelayQueue) DeQueue(topics []string) (*Job, error)

获取任务 任务执行完成后需要调用 Remove 将任务删除

func (*DelayQueue) EnQueue

func (q *DelayQueue) EnQueue(job *Job) error

func (*DelayQueue) Remove

func (q *DelayQueue) Remove(jobId string) error

func (*DelayQueue) Run

func (q *DelayQueue) Run() error

Run transits ready job to ready queue from delay bucket It's a thread safe method, you can run as many as you'd like to

type Job

type Job struct {
	Topic string `json:"topic"`
	ID    string `json:"id"`    // job唯一标识ID
	Delay int64  `json:"delay"` // 延迟时间, unix时间戳
	TTR   int64  `json:"ttr"`   // time-to-run Job执行超时时间。单位:秒。
	Body  []byte `json:"body"`
}

Jump to

Keyboard shortcuts

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