Documentation
¶
Overview ¶
delayqueue 是一款基于Golang开发的高性能延时队列
使用示例:
package main
import (
"fmt"
"github.com/cfanbo/delayqueue"
"time"
)
func consume(entry queue.Entry) {
fmt.Println("当前:", time.Now().Format("2006-01-02 15:04:05"))
fmt.Println("消费:", entry.ConsumeTime().Format("2006-01-02 15:04:05"))
fmt.Println(entry.Body())
fmt.Println("=======================")
}
func main() {
q := New()
q.Put(time.Now().Add(time.Second * 2), "2秒后")
q.Put(time.Now().Add(time.Second * 15), "15秒后")
q.Put(time.Now().Add(time.Second * 8), "8秒后")
q.Put(time.Now().Add(time.Second * 43), "43秒后")
q.Put(time.Now().Add(time.Second * 50), "50秒后")
q.Put(time.Now().Add(time.Second * 28), "28秒后")
//q.Debug(true)
q.Run(consume)
}
Index ¶
Constants ¶
View Source
const (
// 队列总的slot数,每1秒移动一个slot
SlotsCount = 3600
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Elements ¶
type Elements struct {
// contains filtered or unexported fields
}
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func NewQueueOptions ¶
Click to show internal directories.
Click to hide internal directories.