Documentation
¶
Overview ¶
Package queue implements a randomized, time-slized message queue.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RandomQueue ¶
type RandomQueue struct {
// contains filtered or unexported fields
}
RandomQueue implements a time-sliced, randomized message queue.
func New ¶
func New(windowSize, granularity uint64, messagesPerWindow uint64) (*RandomQueue, error)
New creates a new RandomQueue that covers a window of windowSize seconds with the given granularity in seconds. MessagesPerWindow is the total amount of messages expected per windowSize.
func (*RandomQueue) Add ¶
func (queue *RandomQueue) Add(sendTime uint64, message interface{}, unixTimeNow uint64)
Add a message into the RandomQueue for sendTime. If sendTime is 0 or <currentTime, a random sendTime will be generated. unixTimeNow can be the current time, or 0 if we fetch that locally.
func (*RandomQueue) GetSendQueue ¶
func (queue *RandomQueue) GetSendQueue(unixTimeNow uint64) []interface{}
GetSendQueue returns the list of messages that should be sent now. If unixTimeNow is 0, the current time will be used.
Click to show internal directories.
Click to hide internal directories.