Documentation ¶
Overview ¶
Package boltqueue provides a persistent queue or priority queue based on boltdb (https://github.com/boltdb/bolt)
Priority Queue ¶
boltqueue's PQueue type represents a priority queue. Messages may be inserted into the queue at a numeric priority between 0(highest) and 255(lowest). Messages are dequeued following priority order, then time ordering, with the oldest messages of the highest priority emerging first.
Index ¶
- type Message
- type PQueue
- func (b *PQueue) Close() error
- func (b *PQueue) Dequeue(topic string) (*Message, error)
- func (b *PQueue) Enqueue(topic string, priority int, messages ...*Message) error
- func (b *PQueue) Len(topic string, priority int) (int, error)
- func (b *PQueue) Requeue(topic string, priority int, messages ...*Message) error
- func (b *PQueue) Scan(topic string, fn func(m *Message)) error
- func (b *PQueue) ScanWithBreak(topic string, fn func(m *Message) bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
Message represents a message in the priority queue
func NewMessage ¶
NewMessage generates a new priority queue message
func NewMessageB ¶
NewMessageB generates a new priority queue message from a byte slice
type PQueue ¶
type PQueue struct {
// contains filtered or unexported fields
}
PQueue is a priority queue backed by a Bolt database on disk
func NewPQueue ¶
func NewPQueue(db *bolt.DB) *PQueue
NewPQueue consumes an existing opened *bold.DB.
func NewPQueueFromFile ¶
NewPQueueFromFile loads or creates a new PQueue with the given filename
func (*PQueue) Dequeue ¶
Dequeue removes the oldest, highest priority message from the queue and returns it
func (*PQueue) Requeue ¶
Requeue adds a message back into the queue, keeping its precedence. If added at the same priority, it should be among the first to dequeue. If added at a different priority, it will dequeue before newer messages of that priority.