Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyQueue is returned when peek/dequeue is performed on an empty queue ErrEmptyQueue = errors.New("queue is empty") )
Functions ¶
This section is empty.
Types ¶
type BigQueue ¶
type BigQueue struct {
// contains filtered or unexported fields
}
BigQueue implements IBigQueue interface
func NewBigQueue ¶
NewBigQueue constructs an instance of *BigQueue
type IBigQueue ¶
type IBigQueue interface {
IsEmpty() bool
Peek() []byte
Enqueue(elem []byte) error
Dequeue() ([]byte, error)
Close()
}
IBigQueue provides an interface to big, fast and persistent queue
type QueueIndex ¶
type QueueIndex struct {
// contains filtered or unexported fields
}
QueueIndex stores head and tail for a BigQueue in an arena
func NewQueueIndex ¶
func NewQueueIndex(dataDir string) (*QueueIndex, error)
NewQueueIndex creates/reads index for a BigQueue
func (*QueueIndex) Flush ¶
func (i *QueueIndex) Flush()
Flush writes the memory state of the index arena on to disk
func (*QueueIndex) GetHead ¶
func (i *QueueIndex) GetHead() (int, int)
GetHead reads the value of head of the queue from the index arena. Head of a BigQueue can be identified using -
Arena ID
Position (offset) in the arena
<------- head aid ------> <------- head pos ------> +------------+------------+------------+------------+ | byte 01-03 | byte 04-07 | byte 08-11 | byte 12-15 | +------------+------------+------------+------------+
func (*QueueIndex) GetTail ¶
func (i *QueueIndex) GetTail() (int, int)
GetTail reads the values of tail of the queue from the index arena. Tail of a BigQueue, similar to head, can be identified using -
Arena ID
Position (offset) in the arena
<------- tail aid ------> <------- tail pos ------> +------------+------------+------------+------------+ | byte 16-19 | byte 20-23 | byte 24-27 | byte 28-31 | +------------+------------+------------+------------+
func (*QueueIndex) UpdateHead ¶
func (i *QueueIndex) UpdateHead(aid, pos int)
UpdateHead writes the value of head in the index arena
func (*QueueIndex) UpdateTail ¶
func (i *QueueIndex) UpdateTail(aid, pos int)
UpdateTail writes the value of tail in the index arena