queue

package
v0.0.0-...-c262a02 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: Unlicense Imports: 8 Imported by: 0

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.

Jump to

Keyboard shortcuts

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